]> git.imager.perl.org - imager.git/commitdiff
- i_img_pal_new() now releases the image object memory if creation
authorTony Cook <tony@develop=help.com>
Sun, 28 Nov 2004 13:13:12 +0000 (13:13 +0000)
committerTony Cook <tony@develop=help.com>
Sun, 28 Nov 2004 13:13:12 +0000 (13:13 +0000)
  fails.

Changes
palimg.c

diff --git a/Changes b/Changes
index 3b4689b31bd15423f43a5e44c26a5b85bdf581b8..157a24a8e568e0a2bfbc2fc6b1be07c9fdb89114 100644 (file)
--- 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.
 
 =================================================================
 
index ecb14660c1a4c5e07054225d19fd2f1729b8a5d5..870c7a0f8f018bfbee36f7e8ce2fc28a595146a8 100644 (file)
--- 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;
 }
 
 /*