Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-s.b-one.net (mx-s.one.com [91.198.169.250])
	by mail9.b-one.net (Postfix) with ESMTP id AA198400F7E
	for <info@awaresystems.be>; Mon, 30 May 2011 09:28:34 +0200 (CEST)
Received: by mx-s.b-one.net (Postfix, from userid 106)
	id 9FB1EE34973; Mon, 30 May 2011 09:27:58 +0200 (CEST)
X-Virus-Scanned: by one.com
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144]) by
 mx-s.b-one.net (Postfix) with ESMTP id 1684CE2E05B for
 <info@awaresystems.be>; Mon, 30 May 2011 09:27:58 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id D09C686E6E; Mon, 30 May 2011
 02:25:53 -0500 (EST)
Received: from mx.meyering.net (mx.meyering.net [82.230.74.64]) by
 lists.maptools.org (Postfix) with ESMTP id B085086E5B for
 <tiff@lists.maptools.org>; Mon, 30 May 2011 02:03:27 -0500 (EST)
Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id
 C17906009D; Mon, 30 May 2011 09:03:26 +0200 (CEST)
From: Jim Meyering <jim@meyering.net>
To: tiff@lists.maptools.org
Date: Mon, 30 May 2011 09:03:26 +0200
Message-ID: <878vton001.fsf@rho.meyering.net>
Lines: 27
MIME-Version: 1.0
Subject: [Tiff] [PATCH] libtiff: avoid leak upon allocation failure
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

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
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
