From c31fb68ccc0e53d70b21fd068b04b2c1ca4d933f Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 6 Sep 2015 17:18:37 +0200 Subject: [PATCH] fix resource leak in jpwl Fixes #573 --- src/bin/jpwl/convert.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bin/jpwl/convert.c b/src/bin/jpwl/convert.c index 5d9219b3..de04e22f 100644 --- a/src/bin/jpwl/convert.c +++ b/src/bin/jpwl/convert.c @@ -2858,6 +2858,7 @@ opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw for (i = 0; i < w * h; i++) { if (!fread(&value, 1, 1, f)) { fprintf(stderr,"Error reading raw file. End of file probably reached.\n"); + fclose(f); return NULL; } image->comps[compno].data[i] = raw_cp->rawSigned?(char)value:value; @@ -2872,11 +2873,13 @@ opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw unsigned char temp; if (!fread(&temp, 1, 1, f)) { fprintf(stderr,"Error reading raw file. End of file probably reached.\n"); + fclose(f); return NULL; } value = temp << 8; if (!fread(&temp, 1, 1, f)) { fprintf(stderr,"Error reading raw file. End of file probably reached.\n"); + fclose(f); return NULL; } value += temp; @@ -2886,6 +2889,7 @@ opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw } else { fprintf(stderr,"OpenJPEG cannot encode raw components with bit depth higher than 16 bits.\n"); + fclose(f); return NULL; }