Memory leak in contrib/gregbook/readpng.c
In function readpng_get_image: if error happens at png_read_image(…) we go to setjmp(…) where png_ptr and info_ptr will be deleted, but image_data and row_pointers does not.
Possible fix: change what setjmp(…) to this:
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
free(image_data);
free(row_pointers);
return NULL;
}
Thanks. It's probably safer this way:
diff a/contrib/gregbook/readpng.c b/contrib/gregbook/readpng.c
217a218,225
It's been pointed out to me that it's not necessary to check for the NULL pointers; readpng.c guarantees that they are initialized to NULL.
The patch has been applied to the libpngNN branches of the libpng GIT repository and will appear in the next releases.
Last edit: Glenn Randers-Pehrson 2013-03-01
Fixed in libpng-1.5.15 and libpng-1.6.1, thanks.