diff mbox

Fix possible memory leak in dvbca.c

Message ID AANLkTi=8GyE8-EdMfoL+MDXvFGi1V-ikvHc5m=h3Q9zt@mail.gmail.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Tomer Barletz July 27, 2010, 12:58 p.m. UTC
None
diff mbox

Patch

diff -r d3509d6e9499 lib/libdvbapi/dvbca.c
--- a/lib/libdvbapi/dvbca.c	Sat Aug 08 19:17:21 2009 +0200
+++ b/lib/libdvbapi/dvbca.c	Tue Jul 27 15:56:48 2010 +0300
@@ -89,8 +89,10 @@ 
 		     uint8_t *data, uint16_t data_length)
 {
 	uint8_t *buf = malloc(data_length + 2);
-	if (buf == NULL)
+	if (buf == NULL) {
+		free(buf);
 		return -1;
+	}
 
 	buf[0] = slot;
 	buf[1] = connection_id;
@@ -110,8 +112,10 @@ 
 	if (buf == NULL)
 		return -1;
 
-	if ((size = read(fd, buf, data_length+2)) < 2)
+	if ((size = read(fd, buf, data_length+2)) < 2) {
+		free(buf);
 		return -1;
+	}
 
 	*slot = buf[0];
 	*connection_id = buf[1];