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!



Thread

2011.05.30 06:54 "tiff-4.0.0beta7: fix/mark a few minor bugs", by Jim Meyering
2011.05.30 06:54 "[PATCH 1/5] do not dereference NULL upon failed malloc", by Jim Meyering
2011.05.30 06:54 "[PATCH 2/5] avoid set-but-not-used warning from gcc", by Jim Meyering
2011.05.30 06:54 "[PATCH 3/5] tiff2pdf.c: remove decl+set of set-but-not-used local, "written"", by Jim Meyering
2011.05.30 06:54 "[PATCH 4/5] mark NULL-deref and possible overflow", by Jim Meyering
2011.05.30 06:54 "[PATCH 5/5] * rgb2ycbcr.c (cvtRaster): unchecked malloc", by Jim Meyering

2011.05.30 06:54 "[PATCH 1/5] do not dereference NULL upon failed malloc", by Jim Meyering

From: Jim Meyering <meyering@redhat.com>

* libtiff/tif_jpeg.c (JPEGDecodeRaw) [JPEG_LIB_MK1_OR_12BIT]:
Diagnose out-of-memory failure and return 0 rather than
dereferencing NULL.
---
 ChangeLog          |    7 +++++++
 libtiff/tif_jpeg.c |    5 +++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d954ddc..2a9530b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-04-18  Jim Meyering  <meyering@redhat.com>
+
+	do not dereference NULL upon failed malloc
+	* libtiff/tif_jpeg.c (JPEGDecodeRaw) [JPEG_LIB_MK1_OR_12BIT]:
+	Diagnose out-of-memory failure and return 0 rather than
+	dereferencing NULL.
+
 2011-04-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>

 	* libtiff 4.0.0beta7 released.
diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
index b59c630..fb31f48 100644
--- a/libtiff/tif_jpeg.c
+++ b/libtiff/tif_jpeg.c
@@ -1351,6 +1351,11 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
 		unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) *
 		    sp->cinfo.d.output_width *
 		    sp->cinfo.d.num_components);
+		if(tmpbuf==NULL) {
+                        TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
+				     "Out of memory");
+			return 0;
+                }
 #endif

 		do {
-- 
1.7.5.2.660.g9f46c