2011.05.30 06:54 "[Tiff] tiff-4.0.0beta7: fix/mark a few minor bugs", by Jim Meyering

2011.05.30 06:54 "[Tiff] [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