AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
May 2011

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



2011.05.30 07:03 "[PATCH] libtiff: avoid leak upon allocation failure", by Jim Meyering

coverity spotted this potential leak:

2011-05-30  Jim Meyering  <meyering@redhat.com>

	libtiff: avoid leak upon allocation failure
	* libtiff/tif_dirread.c (TIFFFetchStripThing): Free "data" also
	upon failure to allocate "resizeddata".


diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index 6f96ec0..a247a31 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -5347,8 +5347,10 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir,
uint32 nstrips, uint64** lpp)
 	{
 		uint64* resizeddata;
 		resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for
 		strip array");
-		if (resizeddata==0)
+		if (resizeddata==0) {
+			_TIFFfree(data);
 			return(0);
+		}
 		if (dir->tdir_count<(uint64)nstrips)
 		{
 			_TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64));
--
1.7.5.2.660.g9f46c