summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
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.
*/