2010/7/25 Tomer Barletz <barletz@xxxxxxxxx>: > Allocated memory will never get free when read fails. > See attached patch. > > Tomer > Attached a better 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];