diff mbox

[4/7] libdvbv5: make dvb_table_filter_free public

Message ID 1397082420-31198-4-git-send-email-neolynx@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

André Roth April 9, 2014, 10:26 p.m. UTC
make dvb_table_filter_free public so it can be used by
applications.
fix potential double free.

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

Patch

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;