summaryrefslogtreecommitdiff
path: root/src/gd_tiff.c
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2013-04-21 19:07:52 +0200
committerRemi Collet <fedora@famillecollet.com>2013-04-21 19:07:52 +0200
commitf643d8ee6b7d396395654ee5688f02ed2cb1f800 (patch)
treedbe523bce6d19633754428a3270a5ae1a7ce095d /src/gd_tiff.c
parente8edb92b5ec060761ed6db3e1cd460e3fcbc6c83 (diff)
downloadlibgd-f643d8ee6b7d396395654ee5688f02ed2cb1f800.tar.gz
Fix: -Wmaybe-uninitialized (false positive, just to make gcc happy) + fix possible memory leak
Diffstat (limited to 'src/gd_tiff.c')
-rw-r--r--src/gd_tiff.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gd_tiff.c b/src/gd_tiff.c
index c5f71dc..2aebd8f 100644
--- a/src/gd_tiff.c
+++ b/src/gd_tiff.c
@@ -233,9 +233,9 @@ void tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth)
int transparentColorG = -1;
int transparentColorB = -1;
uint16 extraSamples[1];
- uint16 *colorMapRed;
- uint16 *colorMapGreen;
- uint16 *colorMapBlue;
+ uint16 *colorMapRed = NULL;
+ uint16 *colorMapGreen = NULL;
+ uint16 *colorMapBlue = NULL;
tiff_handle *th;
@@ -290,10 +290,13 @@ void tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth)
}
colorMapGreen = (uint16 *) gdMalloc(3 * (1 << bitsPerSample));
if (!colorMapGreen) {
+ gdFree(colorMapRed);
return;
}
colorMapBlue = (uint16 *) gdMalloc(3 * (1 << bitsPerSample));
if (!colorMapBlue) {
+ gdFree(colorMapRed);
+ gdFree(colorMapGreen);
return;
}