From 4841292b5df8f5ed3c92f1760769428ad7500b7a Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 15 Dec 2017 16:49:33 +0100 Subject: [PATCH] Fix resource leak (CID 179466) Coverity report: CID 179466 (#1 of 1): Resource leak (RESOURCE_LEAK) 93. leaked_storage: Variable name going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil --- src/bin/jp2/convert.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index 7040969d..26af53f2 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -1416,6 +1416,9 @@ int imagetopgx(opj_image_t * image, const char *outfile) unsigned char* line_buffer = malloc((size_t)w); if (line_buffer == NULL) { fprintf(stderr, "Out of memory"); + if (total > 256) { + free(name); + } goto fin; } for (j = 0; j < h; j++) {