summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerouault <erouault>2017-04-28 18:08:47 +0000
committererouault <erouault>2017-04-28 18:08:47 +0000
commitaf18bcee9d6f6648a583a543f7e496cf02cacfa8 (patch)
tree30699f05dc105ddb6ed4b3b7cfed195b9a5539a6
parentce502b8863e5ae916e591a6212279966d9563bce (diff)
downloadlibtiff-af18bcee9d6f6648a583a543f7e496cf02cacfa8.tar.gz
* tools/tiff2bw.c: close TIFF handle in error code path.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2677
-rw-r--r--ChangeLog5
-rw-r--r--tools/tiff2bw.c9
2 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 87115215..df446f93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-28 Even Rouault <even.rouault at spatialys.com>
+
+ * tools/tiff2bw.c: close TIFF handle in error code path.
+ Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2677
+
2017-04-27 Even Rouault <even.rouault at spatialys.com>
* litiff/tif_fax3.c: avoid crash in Fax3Close() on empty file.
diff --git a/tools/tiff2bw.c b/tools/tiff2bw.c
index 743f455c..90d3973d 100644
--- a/tools/tiff2bw.c
+++ b/tools/tiff2bw.c
@@ -1,4 +1,4 @@
-/* $Id: tiff2bw.c,v 1.19 2016-08-15 22:01:31 erouault Exp $ */
+/* $Id: tiff2bw.c,v 1.20 2017-04-28 18:08:47 erouault Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -165,23 +165,27 @@ main(int argc, char* argv[])
fprintf(stderr,
"%s: Bad photometric; can only handle RGB and Palette images.\n",
argv[optind]);
+ TIFFClose(in);
return (-1);
}
TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
if (samplesperpixel != 1 && samplesperpixel != 3) {
fprintf(stderr, "%s: Bad samples/pixel %u.\n",
argv[optind], samplesperpixel);
+ TIFFClose(in);
return (-1);
}
if( photometric == PHOTOMETRIC_RGB && samplesperpixel != 3) {
fprintf(stderr, "%s: Bad samples/pixel %u for PHOTOMETRIC_RGB.\n",
argv[optind], samplesperpixel);
+ TIFFClose(in);
return (-1);
}
TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample);
if (bitspersample != 8) {
fprintf(stderr,
" %s: Sorry, only handle 8-bit samples.\n", argv[optind]);
+ TIFFClose(in);
return (-1);
}
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w);
@@ -190,7 +194,10 @@ main(int argc, char* argv[])
out = TIFFOpen(argv[optind+1], "w");
if (out == NULL)
+ {
+ TIFFClose(in);
return (-1);
+ }
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, w);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, h);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);