From: Takeshi Abe Date: Wed, 11 Feb 2009 17:56:17 +0000 (+0000) Subject: - fixed memory leaks in gdImageCreateFromXpm() X-Git-Tag: php-5.4.0alpha1~191^2~4294 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c0cbee415640142933df027a6c25d948d3d4f56;p=php - fixed memory leaks in gdImageCreateFromXpm() - dropped unused codes --- diff --git a/ext/gd/libgd/gdxpm.c b/ext/gd/libgd/gdxpm.c index 785afb3680..73f86e5df7 100644 --- a/ext/gd/libgd/gdxpm.c +++ b/ext/gd/libgd/gdxpm.c @@ -22,7 +22,6 @@ gdImagePtr gdImageCreateFromXpm (char *filename) int i, j, k, number; char buf[5]; gdImagePtr im = 0; - char *apixel; int *pointer; int red = 0, green = 0, blue = 0; int *colors; @@ -34,7 +33,7 @@ gdImagePtr gdImageCreateFromXpm (char *filename) } if (!(im = gdImageCreate(image.width, image.height))) { - return 0; + goto done; } number = image.ncolors; @@ -116,14 +115,8 @@ gdImagePtr gdImageCreateFromXpm (char *filename) colors[i] = gdImageColorResolve(im, red, green, blue); - if (colors[i] == -1) { - php_gd_error("ARRRGH"); - } } - apixel = (char *) gdMalloc(image.cpp + 1); - apixel[image.cpp] = '\0'; - pointer = (int *) image.data; for (i = 0; i < image.height; i++) { for (j = 0; j < image.width; j++) { @@ -132,8 +125,10 @@ gdImagePtr gdImageCreateFromXpm (char *filename) } } - gdFree(apixel); gdFree(colors); + done: + XpmFreeXpmImage(&image); + XpmFreeXpmInfo(&info); return im; } #endif