From 3ac3b44048459afd7b8dc06e4dbb648c058706ce Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Wed, 11 Feb 2009 17:56:44 +0000 Subject: [PATCH] MFH: - fixed memory leaks in gdImageCreateFromXpm() - dropped unused codes --- ext/gd/libgd/gdxpm.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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 -- 2.50.1