Skip to contentSkip to conversation

batadv-vis: Avoid file handler leak after failed realloc

PATCH Applied Sven Eckelmann 2 participants 2 messages May 27, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batadv-vis: Avoid file handler leak after failed realloc

The read_file function opens the file and thus has to close the filehandler after an realloc error. This was forgotten in the fix 0ad384e11ed039d4c3025a7eaf19fe6bcfd41acf ("batadv-vis: Avoid memory leak after failed realloc").

---
 vis/vis.c | 1 +
 1 file changed, 1 insertion(+)
vis/vis.c +1 -0
index f429942..55c2dad 100644
@@ -56,6 +56,7 @@ static char *read_file(char *fname)
 		buf_tmp = realloc(buf, size + 4097);
 		if (!buf_tmp) {
 			free(buf);
+			fclose(fp);
 			return NULL;
 		}
 
Signature · 1 line
2.0.0.rc4
#1 lore raw
Quoted 5 lines

The read_file function opens the file and thus has to close the filehandler after an realloc error. This was forgotten in the fix 0ad384e11ed039d4c3025a7eaf19fe6bcfd41acf ("batadv-vis: Avoid memory leak after failed realloc").

Applied in revision 3b72283

Thanks,
Simon