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 06:33 "[PATCH] tiff2ps: avoid NULL-dereference on allocation failure", by Jim Meyering

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