From 4dc7c46b87888aa9dbefb8ecd8d0ca2d0825b8a2 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Sun, 28 Nov 2004 13:13:12 +0000 Subject: [PATCH] - i_img_pal_new() now releases the image object memory if creation fails. --- Changes | 2 ++ palimg.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 3b4689b3..157a24a8 100644 --- a/Changes +++ b/Changes @@ -912,6 +912,8 @@ Revision history for Perl extension Imager. and skips to that offset before reading image data. Previously this value was read but otherwise ignored. - added --palette action to tools/imager +- i_img_pal_new() now releases the image object memory if creation + fails. ================================================================= diff --git a/palimg.c b/palimg.c index ecb14660..870c7a0f 100644 --- a/palimg.c +++ b/palimg.c @@ -127,7 +127,12 @@ i_img *i_img_pal_new(int x, int y, int channels, int maxpal) { i_img *im; mm_log((1, "i_img_pal_new(x %d, y %d, channels %d, maxpal %d)\n", x, y, channels, maxpal)); im = mymalloc(sizeof(i_img)); - return i_img_pal_new_low(im, x, y, channels, maxpal); + if (!i_img_pal_new_low(im, x, y, channels, maxpal)) { + myfree(im); + im = NULL; + } + + return im; } /* -- 2.39.5