summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-04-25 18:23:52 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-04-25 18:23:52 (GMT)
commitbcca65eae4c1a94002d5f9aa9bd7fb75dc48b0fa (patch)
tree1abbd463f4518655d16d1798d16795640a21d960 /generic
parent0ec04490736cdf3891388a3a1e9cf8e8cef380f5 (diff)
downloadtk-bcca65eae4c1a94002d5f9aa9bd7fb75dc48b0fa.zip
tk-bcca65eae4c1a94002d5f9aa9bd7fb75dc48b0fa.tar.gz
tk-bcca65eae4c1a94002d5f9aa9bd7fb75dc48b0fa.tar.bz2
* generic/tkImgPNG.c (ReadIDAT, DecodePNG): Move the check for overall
termination of the compressed stream until after the final IDAT has been read, so that multi-segment images will work right. Reported by Andy Goth on the Wiki.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkImgPNG.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c
index c138b78..ec84a1c 100644
--- a/generic/tkImgPNG.c
+++ b/generic/tkImgPNG.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkImgPNG.c,v 1.6 2010/04/12 08:40:15 dkf Exp $
+ * RCS: @(#) $Id: tkImgPNG.c,v 1.7 2010/04/25 18:23:52 dkf Exp $
*/
#include "tkInt.h"
@@ -2130,26 +2130,18 @@ ReadIDAT(
}
/*
- * Ensure that when we've got to the end of the compressed data, we've
+ * Ensure that if we've got to the end of the compressed data, we've
* also got to the end of the compressed stream. This sanity check is
* enforced by most PNG readers.
*/
- if (!Tcl_ZlibStreamEof(pngPtr->stream)) {
- Tcl_AppendResult(interp, "unfinalized data stream in PNG data", NULL);
- return TCL_ERROR;
- }
if (chunkSz != 0) {
Tcl_AppendResult(interp,
"compressed data after stream finalize in PNG data", NULL);
return TCL_ERROR;
}
- if (CheckCRC(interp, pngPtr, crc) == TCL_ERROR) {
- return TCL_ERROR;
- }
-
- return TCL_OK;
+ return CheckCRC(interp, pngPtr, crc);
}
/*
@@ -2456,9 +2448,9 @@ DecodePNG(
Tcl_IncrRefCount(pngPtr->lastLineObj);
pngPtr->thisLineObj = Tcl_NewObj();
Tcl_IncrRefCount(pngPtr->thisLineObj);
+
pngPtr->block.pixelPtr = (unsigned char *)
attemptckalloc(pngPtr->blockLen);
-
if (!pngPtr->block.pixelPtr) {
Tcl_SetResult(interp, "Memory allocation failed", TCL_STATIC);
return TCL_ERROR;
@@ -2504,6 +2496,17 @@ DecodePNG(
}
/*
+ * Ensure that we've got to the end of the compressed stream now that
+ * there are no more IDAT segments. This sanity check is enforced by most
+ * PNG readers.
+ */
+
+ if (!Tcl_ZlibStreamEof(pngPtr->stream)) {
+ Tcl_AppendResult(interp, "unfinalized data stream in PNG data", NULL);
+ return TCL_ERROR;
+ }
+
+ /*
* Now skip the remaining chunks which we're also not interested in.
*/