[PATCH 4/7] libdvbv5: make dvb_table_filter_free public

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



make dvb_table_filter_free public so it can be used by
applications.
fix potential double free.

Signed-off-by: André Roth <neolynx@xxxxxxxxx>
---
 lib/include/libdvbv5/dvb-scan.h |    2 ++
 lib/libdvbv5/dvb-scan.c         |   10 ++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/include/libdvbv5/dvb-scan.h b/lib/include/libdvbv5/dvb-scan.h
index 206d409..f0af9d7 100644
--- a/lib/include/libdvbv5/dvb-scan.h
+++ b/lib/include/libdvbv5/dvb-scan.h
@@ -74,6 +74,8 @@ struct dvb_table_filter {
 	void *priv;
 };
 
+void dvb_table_filter_free(struct dvb_table_filter *sect);
+
 int dvb_read_section(struct dvb_v5_fe_parms *parms, int dmx_fd, unsigned char tid, uint16_t pid, void **table,
 		unsigned timeout);
 
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index e522225..d8b3953 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -158,10 +158,12 @@ static int dvb_parse_section_alloc(struct dvb_v5_fe_parms *parms,
 	return 0;
 }
 
-static void dvb_parse_section_free(struct dvb_table_filter *sect)
+void dvb_table_filter_free(struct dvb_table_filter *sect)
 {
-	if (sect->priv)
+	if (sect->priv) {
 		free(sect->priv);
+		sect->priv = NULL;
+	}
 }
 
 static int dvb_parse_section(struct dvb_v5_fe_parms *parms,
@@ -280,7 +282,7 @@ int dvb_read_sections(struct dvb_v5_fe_parms *parms, int dmx_fd,
 	if (!buf) {
 		dvb_perror("Out of memory");
 		dvb_dmx_stop(dmx_fd);
-		dvb_parse_section_free(sect);
+		dvb_table_filter_free(sect);
 		return -1;
 	}
 
@@ -327,7 +329,7 @@ int dvb_read_sections(struct dvb_v5_fe_parms *parms, int dmx_fd,
 	} while (!ret);
 	free(buf);
 	dvb_dmx_stop(dmx_fd);
-	dvb_parse_section_free(sect);
+	dvb_table_filter_free(sect);
 
 	if (ret > 0)
 		ret = 0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux