* tools/tiff2bw.c: close TIFF handle in error code path.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2677
This commit is contained in:
parent
fa55777370
commit
d606ea22bb
@ -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>
|
2017-04-27 Even Rouault <even.rouault at spatialys.com>
|
||||||
|
|
||||||
* litiff/tif_fax3.c: avoid crash in Fax3Close() on empty file.
|
* litiff/tif_fax3.c: avoid crash in Fax3Close() on empty file.
|
||||||
|
@ -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
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -165,23 +165,27 @@ main(int argc, char* argv[])
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: Bad photometric; can only handle RGB and Palette images.\n",
|
"%s: Bad photometric; can only handle RGB and Palette images.\n",
|
||||||
argv[optind]);
|
argv[optind]);
|
||||||
|
TIFFClose(in);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
|
TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
|
||||||
if (samplesperpixel != 1 && samplesperpixel != 3) {
|
if (samplesperpixel != 1 && samplesperpixel != 3) {
|
||||||
fprintf(stderr, "%s: Bad samples/pixel %u.\n",
|
fprintf(stderr, "%s: Bad samples/pixel %u.\n",
|
||||||
argv[optind], samplesperpixel);
|
argv[optind], samplesperpixel);
|
||||||
|
TIFFClose(in);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if( photometric == PHOTOMETRIC_RGB && samplesperpixel != 3) {
|
if( photometric == PHOTOMETRIC_RGB && samplesperpixel != 3) {
|
||||||
fprintf(stderr, "%s: Bad samples/pixel %u for PHOTOMETRIC_RGB.\n",
|
fprintf(stderr, "%s: Bad samples/pixel %u for PHOTOMETRIC_RGB.\n",
|
||||||
argv[optind], samplesperpixel);
|
argv[optind], samplesperpixel);
|
||||||
|
TIFFClose(in);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
||||||
if (bitspersample != 8) {
|
if (bitspersample != 8) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" %s: Sorry, only handle 8-bit samples.\n", argv[optind]);
|
" %s: Sorry, only handle 8-bit samples.\n", argv[optind]);
|
||||||
|
TIFFClose(in);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w);
|
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w);
|
||||||
@ -190,7 +194,10 @@ main(int argc, char* argv[])
|
|||||||
|
|
||||||
out = TIFFOpen(argv[optind+1], "w");
|
out = TIFFOpen(argv[optind+1], "w");
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
|
{
|
||||||
|
TIFFClose(in);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
}
|
||||||
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, w);
|
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, w);
|
||||||
TIFFSetField(out, TIFFTAG_IMAGELENGTH, h);
|
TIFFSetField(out, TIFFTAG_IMAGELENGTH, h);
|
||||||
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
|
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
|
||||||
|
Loading…
Reference in New Issue
Block a user