From 173eaee9c28c8c23096acbdcadec5ffc2e5c6bae Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 14 Jun 2014 19:34:03 +0200 Subject: [PATCH] wrlib: initialise value for variable to avoid possible crash (Coverity #50245) As pointed by Coverity, there's a free on the content of this buffer at function's end, but if the image's width or height is lower than 1 then we could reach this free before allocating anything, thus having an uninitialised pointer. Signed-off-by: Christophe CURIS --- wrlib/load_jpeg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/wrlib/load_jpeg.c b/wrlib/load_jpeg.c index ded519e9..64eeb481 100644 --- a/wrlib/load_jpeg.c +++ b/wrlib/load_jpeg.c @@ -132,6 +132,7 @@ RImage *RLoadJPEG(const char *file_name) jpeg_read_header(&cinfo, TRUE); if (cinfo.image_width < 1 || cinfo.image_height < 1) { + buffer[0] = NULL; /* Initialize pointer to avoid spurious free in cleanup code */ RErrorCode = RERR_BADIMAGEFILE; goto bye; }