diff options
author | tabe <none@none> | 2009-03-14 04:16:49 +0000 |
---|---|---|
committer | tabe <none@none> | 2009-03-14 04:16:49 +0000 |
commit | c719401fcd264a531acf3e38e321201f668cbc28 (patch) | |
tree | b55ccb5ab475b5ac7e2e8d950d830d4b57b9ca46 | |
parent | 1f3a89eed9d2583c5926f9505036a939475f8a79 (diff) | |
download | libgd-c719401fcd264a531acf3e38e321201f668cbc28.tar.gz |
fixed a slim chance of memory leaks.
-rw-r--r-- | src/gd_png.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/gd_png.c b/src/gd_png.c index 00ee331..1bc4ee1 100644 --- a/src/gd_png.c +++ b/src/gd_png.c @@ -762,14 +762,13 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) png_bytep *prow_pointers; int saveAlphaFlag = im->saveAlphaFlag; if (overflow2(sizeof (png_bytep), height)) { - return; + goto bail; } row_pointers = gdMalloc (sizeof (png_bytep) * height); if (row_pointers == NULL) { fprintf (stderr, "gd-png error: unable to allocate row_pointers\n"); - /* 2.0.29: return was missing */ - return; + goto bail; } prow_pointers = row_pointers; for (j = 0; j < height; ++j) @@ -782,7 +781,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) gdFree (row_pointers[i]); /* 2.0.29: memory leak TBB */ gdFree(row_pointers); - return; + goto bail; } pOutputRow = *prow_pointers++; pThisRow = *ptpixels++; @@ -820,15 +819,13 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) { png_bytep *row_pointers; if (overflow2(sizeof (png_bytep), height)) { - return; + goto bail; } row_pointers = gdMalloc (sizeof (png_bytep) * height); if (row_pointers == NULL) { - fprintf (stderr, - "gd-png error: unable to allocate row_pointers\n"); - /* TBB: return missing */ - return; + fprintf (stderr, "gd-png error: unable to allocate row_pointers\n"); + goto bail; } for (j = 0; j < height; ++j) { @@ -839,7 +836,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) gdFree (row_pointers[i]); /* TBB: memory leak */ gdFree (row_pointers); - return; + goto bail; } for (i = 0; i < width; ++i) row_pointers[j][i] = mapping[im->pixels[j][i]]; |