From 1fb04bec99c6930aac702e74bf85c7de2519fed1 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Fri, 5 Apr 2013 11:24:59 -0700 Subject: [PATCH] pngdec: Avoid a double-free. Earlier, at line#275, if ok == 0, it would have triggered a double free of 'rgb'. Change-Id: Iaee1f35824a66f6e4b488e523416f73b87c5ec30 (cherry picked from commit b68912af2c8cefa52bb16634b077938ff074f03a) --- examples/pngdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/pngdec.c b/examples/pngdec.c index 7a7649c7..78353560 100644 --- a/examples/pngdec.c +++ b/examples/pngdec.c @@ -207,7 +207,6 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha, Error: MetadataFree(metadata); png_destroy_read_struct(&png, &info, &end_info); - free(rgb); goto End; } @@ -270,13 +269,13 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha, pic->use_argb = 1; ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, stride) : WebPPictureImportRGB(pic, rgb, stride); - free(rgb); if (!ok) { goto Error; } End: + free(rgb); return ok; } #else // !WEBP_HAVE_PNG