From: Christoph M. Becker Date: Mon, 3 Oct 2016 10:11:46 +0000 (+0200) Subject: Move freeing of truecolor pixels to a function X-Git-Tag: php-7.2.0alpha1~1215 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b134a1dcbc0c168c6c43a838638094d12bdb3d4;p=php Move freeing of truecolor pixels to a function We port . --- diff --git a/ext/gd/libgd/gd_topal.c b/ext/gd/libgd/gd_topal.c index 5b84855656..a92a7acb17 100644 --- a/ext/gd/libgd/gd_topal.c +++ b/ext/gd/libgd/gd_topal.c @@ -1442,6 +1442,19 @@ int gdImageTrueColorToPalette (gdImagePtr im, int dither, int colorsWanted) return gdImageTrueColorToPaletteBody(im, dither, colorsWanted, 0); } +static void free_truecolor_image_data(gdImagePtr oim) +{ + int i; + oim->trueColor = 0; + /* Junk the truecolor pixels */ + for (i = 0; i < oim->sy; i++) + { + gdFree (oim->tpixels[i]); + } + gdFree (oim->tpixels); + oim->tpixels = 0; +} + /* * Module initialization routine for 2-pass color quantization. */ @@ -1605,16 +1618,11 @@ static int gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int colors /* Success! Get rid of the truecolor image data. */ conversionSucceeded = TRUE; - if (!cimP) { - oim->trueColor = 0; - /* Junk the truecolor pixels */ - for (i = 0; i < oim->sy; i++) - { - gdFree (oim->tpixels[i]); - } - gdFree (oim->tpixels); - oim->tpixels = 0; - } + if (!cimP) + { + free_truecolor_image_data(oim); + } + goto freeQuantizeData; /* Tediously free stuff. */ outOfMemory: