diff options
author | Ken Hughes <khughes@pacific.edu> | 2007-01-22 08:07:16 +0300 |
---|---|---|
committer | Ken Hughes <khughes@pacific.edu> | 2007-01-22 08:07:16 +0300 |
commit | 1ff94bec3806d6bddc9f5003750c4201cdf9f2d5 (patch) | |
tree | 37e4493b32195279c2dabd951a25042ccfef3959 /source/blender/imbuf/intern/png.c | |
parent | da84ec90ae9e1e696cd76f8930c11605298c0d9c (diff) |
Bugfix: imb_savepng() didn't deallocate memory under some error conditions.
Diffstat (limited to 'source/blender/imbuf/intern/png.c')
-rw-r--r-- | source/blender/imbuf/intern/png.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 0ebdeeca343..46c5232a61a 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -189,7 +189,10 @@ short imb_savepng(struct ImBuf *ibuf, char *name, int flags) Flush); } else { fp = fopen(name, "wb"); - if (!fp) return 0; + if (!fp) { + MEM_freeN(pixels); + return 0; + } png_init_io(png_ptr, fp); } @@ -222,8 +225,9 @@ short imb_savepng(struct ImBuf *ibuf, char *name, int flags) // allocate memory for an array of row-pointers row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); if (row_pointers == NULL) { - printf("Cannot allocate row-pointers array\n"); - return 0; + printf("Cannot allocate row-pointers array\n"); + MEM_freeN(pixels); + return 0; } // set the individual row-pointers to point at the correct offsets |