From 0c55ccfd295cd5a139e0f4f37a3373ebbf85634a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 22 Jan 2013 22:43:33 +0000 Subject: [PATCH] fixed memory leak in jedutil (nw) --- src/tools/jedutil.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tools/jedutil.c b/src/tools/jedutil.c index f6b5ba158f1..050da77b64f 100644 --- a/src/tools/jedutil.c +++ b/src/tools/jedutil.c @@ -3338,7 +3338,10 @@ static int command_convert(int argc, char *argv[]) /* read the source file */ err = read_source_file(srcfile); if (err != 0) + { + free(srcbuf); return 1; + } memset(&jed, 0, sizeof(jed)); @@ -3374,6 +3377,7 @@ static int command_convert(int argc, char *argv[]) if (!dstbuf) { fprintf(stderr, "Unable to allocate %d bytes for the target buffer!\n", (int)dstbuflen); + free(srcbuf); return 1; } dstbuflen = jedbin_output(&jed, dstbuf, dstbuflen); @@ -3401,6 +3405,7 @@ static int command_convert(int argc, char *argv[]) if (!dstbuf) { fprintf(stderr, "Unable to allocate %d bytes for the target buffer!\n", (int)dstbuflen); + free(srcbuf); return 1; } dstbuflen = jed_output(&jed, dstbuf, dstbuflen); @@ -3408,6 +3413,7 @@ static int command_convert(int argc, char *argv[]) /* write the destination file */ err = write_dest_file(dstfile); + free(srcbuf); if (err != 0) return 1; @@ -3453,7 +3459,10 @@ static int command_view(int argc, char *argv[]) /* read the source file */ err = read_source_file(srcfile); if (err != 0) + { + free(srcbuf); return 1; + } /* if the source is JED, convert to binary */ if (is_jed) @@ -3488,10 +3497,11 @@ static int command_view(int argc, char *argv[]) else { fprintf(stderr, "Viewing product terms not supported for this pal type."); - + free(srcbuf); return 1; } + free(srcbuf); return 0; }