Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-k.b-one.net (mx-k.one.com [91.198.169.58])
	by mail9.b-one.net (Postfix) with ESMTP id DE12A400F7E
	for <info@awaresystems.be>; Mon, 30 May 2011 08:42:46 +0200 (CEST)
Received: by mx-k.b-one.net (Postfix, from userid 106)
	id D07FA847C6C7; Mon, 30 May 2011 08:42:31 +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-k.b-one.net (Postfix) with ESMTP id 16DAC847C6B1 for
 <info@awaresystems.be>; Mon, 30 May 2011 08:42:31 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id 7AED386E39; Mon, 30 May 2011
 01:40:27 -0500 (EST)
Received: from mx.meyering.net (mx.meyering.net [82.230.74.64]) by
 lists.maptools.org (Postfix) with ESMTP id A7BFF86C59 for
 <tiff@lists.maptools.org>; Mon, 30 May 2011 01:33:33 -0500 (EST)
Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id
 F3C0A60092; Mon, 30 May 2011 08:33:32 +0200 (CEST)
From: Jim Meyering <jim@meyering.net>
To: tiff@lists.maptools.org
Date: Mon, 30 May 2011 08:33:32 +0200
Message-ID: <87lixon1dv.fsf@rho.meyering.net>
Lines: 31
MIME-Version: 1.0
Subject: [Tiff] [PATCH] tiff2ps: avoid NULL-dereference on 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 the potential NULL-deref:

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

	tiff2ps: avoid NULL-dereference on allocation failure
	* tools/tiff2ps.c (PSDataBW): Zero buffer *after* checking
	for allocation failure, not before.

diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c
index 1b553c2..27901b9 100644
--- a/tools/tiff2ps.c
+++ b/tools/tiff2ps.c
@@ -2595,13 +2595,14 @@ PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)

 	(void) w; (void) h;
 	tf_buf = (unsigned char *) _TIFFmalloc(stripsize);
-	// FIXME
-        memset(tf_buf, 0, stripsize);
 	if (tf_buf == NULL) {
 		TIFFError(filename, "No space for scanline buffer");
 		return;
 	}

+	// FIXME
+	memset(tf_buf, 0, stripsize);
+
 #if defined( EXP_ASCII85ENCODER )
 	if ( ascii85 ) {
 	    /*
--
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/
