From: Tony Cook Date: Wed, 9 Mar 2016 10:06:51 +0000 (+1100) Subject: fix a memory leak when failing to write a 2 color icon image X-Git-Tag: v1.004_001~4 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/6b0009e591755d68a0a4d3be352a8eab78710ef3 fix a memory leak when failing to write a 2 color icon image --- diff --git a/ICO/ICO.pm b/ICO/ICO.pm index aeffd79d..67d2772f 100644 --- a/ICO/ICO.pm +++ b/ICO/ICO.pm @@ -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); diff --git a/ICO/msicon.c b/ICO/msicon.c index 7d31690f..85e3e284 100644 --- a/ICO/msicon.c +++ b/ICO/msicon.c @@ -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;