summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfriesen <bfriesen>2015-08-15 20:13:07 +0000
committerbfriesen <bfriesen>2015-08-15 20:13:07 +0000
commitdc6180f93bba6569f6ec31202a4e546ee7a766e1 (patch)
tree5623940391fe9d5466772df16856cfe40687e6c7
parenta8431c5f1a69d7fbc0fbb31d862ac57dcb59ca26 (diff)
downloadlibtiff-dc6180f93bba6569f6ec31202a4e546ee7a766e1.tar.gz
tif_jpeg.c consistency fixes.
-rw-r--r--ChangeLog6
-rw-r--r--libtiff/tif_jpeg.c30
2 files changed, 32 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b7581f7d..40c47e19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-08-15 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
+
+ * libtiff/tif_jpeg.c: Applied patch by Räisä Olli to assure that
+ client_data is initialized to a known value, and to report an
+ error on two memory allocation failures.
+
2015-08-13 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
* CMakeLists.txt: Applied patch by Roger Leigh to fix libtiffxx
diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
index d9276caf..a970eb15 100644
--- a/libtiff/tif_jpeg.c
+++ b/libtiff/tif_jpeg.c
@@ -1,4 +1,4 @@
-/* $Id: tif_jpeg.c,v 1.118 2015-06-10 13:17:41 bfriesen Exp $ */
+/* $Id: tif_jpeg.c,v 1.119 2015-08-15 20:13:07 bfriesen Exp $ */
/*
* Copyright (c) 1994-1997 Sam Leffler
@@ -252,6 +252,9 @@ TIFFjpeg_create_compress(JPEGState* sp)
sp->err.error_exit = TIFFjpeg_error_exit;
sp->err.output_message = TIFFjpeg_output_message;
+ /* set client_data to avoid UMR warning from tools like Purify */
+ sp->cinfo.c.client_data = NULL;
+
return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c));
}
@@ -263,6 +266,9 @@ TIFFjpeg_create_decompress(JPEGState* sp)
sp->err.error_exit = TIFFjpeg_error_exit;
sp->err.output_message = TIFFjpeg_output_message;
+ /* set client_data to avoid UMR warning from tools like Purify */
+ sp->cinfo.d.client_data = NULL;
+
return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d));
}
@@ -1889,7 +1895,14 @@ JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
{
line16_count = (sp->bytesperline * 2) / 3;
line16 = (short *) _TIFFmalloc(sizeof(short) * line16_count);
- // FIXME: undiagnosed malloc failure
+ if (!line16)
+ {
+ TIFFErrorExt(tif->tif_clientdata,
+ "JPEGEncode",
+ "Failed to allocate memory");
+
+ return 0;
+ }
}
while (nrows-- > 0) {
@@ -2379,8 +2392,17 @@ here hopefully is harmless.
*/
sp->jpegtables_length = SIZE_OF_JPEGTABLES;
sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length);
- // FIXME: NULL-deref after malloc failure
- _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES);
+ if (sp->jpegtables)
+ {
+ _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES);
+ }
+ else
+ {
+ TIFFErrorExt(tif->tif_clientdata,
+ "TIFFInitJPEG",
+ "Failed to allocate memory for JPEG tables");
+ return 0;
+ }
#undef SIZE_OF_JPEGTABLES
}