fix some coverity reported problems

This commit is contained in:
Frank Warmerdam 2008-05-23 17:24:41 +00:00
parent e6f5098ee8
commit 09fe8fabf4
4 changed files with 23 additions and 9 deletions

View File

@ -1,3 +1,12 @@
2008-05-23 Frank Warmerdam <warmerdam@pobox.com>
* tools/rgb2ycbcr.c: fix memory leak of raster buffer.
* tools/tiffcp.c: Simplify inknames code to avoid pointless test.
Cleanup scanline allocation to avoid coverity warning.
* tools/thumbnail.c: Check for TIFFOpen() failure.
2008-05-18 Frank Warmerdam <warmerdam@pobox.com>
* libtiff/tif_dirinfo.c: Use TIFF_SETGET_ASCII for PIXAR_TEXTUREFORMAT

View File

@ -1,4 +1,4 @@
/* $Id: rgb2ycbcr.c,v 1.9 2004-09-03 07:57:13 dron Exp $ */
/* $Id: rgb2ycbcr.c,v 1.10 2008-05-23 17:24:41 fwarmerdam Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -278,6 +278,7 @@ tiffcvt(TIFF* in, TIFF* out)
float floatv;
char *stringv;
uint32 longv;
int result;
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
@ -322,7 +323,9 @@ tiffcvt(TIFF* in, TIFF* out)
rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
return (cvtRaster(out, raster, width, height));
result = cvtRaster(out, raster, width, height);
_TIFFfree(raster);
return result;
}
char* stuff[] = {

View File

@ -1,4 +1,4 @@
/* $Id: thumbnail.c,v 1.9 2005-06-23 10:54:02 dron Exp $ */
/* $Id: thumbnail.c,v 1.10 2008-05-23 17:24:41 fwarmerdam Exp $ */
/*
* Copyright (c) 1994-1997 Sam Leffler
@ -100,6 +100,8 @@ main(int argc, char* argv[])
if (out == NULL)
return 2;
in = TIFFOpen(argv[optind], "r");
if( in == NULL )
return 2;
thumbnail = (uint8*) _TIFFmalloc(tnw * tnh);
if (!thumbnail) {

View File

@ -1,4 +1,4 @@
/* $Id: tiffcp.c,v 1.39 2007-06-20 08:36:42 joris Exp $ */
/* $Id: tiffcp.c,v 1.40 2008-05-23 17:24:41 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -720,10 +720,8 @@ tiffcp(TIFF* in, TIFF* out)
const char* cp = inknames;
while (ninks > 1) {
cp = strchr(cp, '\0');
if (cp) {
cp++;
inknameslen += (strlen(cp) + 1);
}
cp++;
inknameslen += (strlen(cp) + 1);
ninks--;
}
TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames);
@ -1178,10 +1176,12 @@ DECLAREreadFunc(readSeparateStripsIntoBuffer)
{
int status = 1;
tsize_t scanlinesize = TIFFScanlineSize(in);
tdata_t scanline = _TIFFmalloc(scanlinesize);
tdata_t scanline;
if (!scanlinesize)
return 0;
scanline = _TIFFmalloc(scanlinesize);
(void) imagewidth;
if (scanline) {
uint8* bufp = (uint8*) buf;