]> git.imager.perl.org - imager.git/commitdiff
fix a memory leak when failing to write a 2 color icon image
authorTony Cook <tony@develop-help.com>
Wed, 9 Mar 2016 10:06:51 +0000 (21:06 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 9 Mar 2016 10:06:51 +0000 (21:06 +1100)
ICO/ICO.pm
ICO/msicon.c

index aeffd79ddd0cbcbc56b4b357583f8d06c487759d..67d2772f3f0ccaeae42e57d51ac32050f2c9d752 100644 (file)
@@ -4,7 +4,7 @@ use Imager;
 use vars qw($VERSION @ISA);
 
 BEGIN {
-  $VERSION = "0.04";
+  $VERSION = "0.05";
   
   require XSLoader;
   XSLoader::load('Imager::File::ICO', $VERSION);
index 7d31690f61ca1c6d22be0886b8ecc53e0071c44b..85e3e28438b862958fa015e967a4090bf49f004f 100644 (file)
@@ -1425,7 +1425,7 @@ Write 1 bit image data.
 static int
 write_1_bit(i_io_glue_t *ig, ico_image_t const *image, int *error) {
   int line_size = (image->width + 31) / 32 * 4;
-  unsigned char *writebuf = malloc(line_size);
+  unsigned char *writebuf;
   unsigned char *outp;
   unsigned char const *data, *pixelp;
   int x,y;
@@ -1438,6 +1438,7 @@ write_1_bit(i_io_glue_t *ig, ico_image_t const *image, int *error) {
   if (!write_palette(ig, image, error))
     return 0;
 
+  writebuf = malloc(line_size);
   if (!writebuf) {
     *error = ICOERR_Out_Of_Memory;
     return 0;