[PATCH 07/13] Plug potential memory leak in try_to_xslt_open_csv

Anton Lundin glance at acc.umu.se
Tue Dec 10 15:53:31 UTC 2013


Free temp buffer if realloc fails.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/file.c b/file.c
index a8c0142..1e141b7 100644
--- a/file.c
+++ b/file.c
@@ -122,8 +122,10 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, char
 		memcpy(mem->buffer + mem->size + 5, "</csv>", 7);
 		mem->buffer = buf;
 		mem->size += strlen("<csv></csv>");
-	} else
+	} else {
+		free(mem->buffer);
 		return 1;
+	}
 
 	return 0;
 }
-- 
1.8.3.2



More information about the subsurface mailing list