summaryrefslogtreecommitdiffstats
path: root/generic/tclZlib.c
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2009-07-10 17:37:18 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2009-07-10 17:37:18 (GMT)
commitb1b828fd60bfd07a6e17453f3d2ffe646bcad60c (patch)
tree8f3fe2fe7cb2e4309ee617233cd7d2a53f25e035 /generic/tclZlib.c
parent02ba54c693aaea66388d4d5293c510e999209910 (diff)
downloadtcl-b1b828fd60bfd07a6e17453f3d2ffe646bcad60c.zip
tcl-b1b828fd60bfd07a6e17453f3d2ffe646bcad60c.tar.gz
tcl-b1b828fd60bfd07a6e17453f3d2ffe646bcad60c.tar.bz2
ZlibTransformClose may be called with a NULL interpreter during finalization and
Tcl_SetChannelError requires a list. Added some tests to ensure error propagation from the zlib library to the interp.
Diffstat (limited to 'generic/tclZlib.c')
-rw-r--r--generic/tclZlib.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 96d68c1..5dc8c2e 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclZlib.c,v 1.29 2009/07/09 22:48:44 patthoyts Exp $
+ * RCS: @(#) $Id: tclZlib.c,v 1.30 2009/07/10 17:37:18 patthoyts Exp $
*/
#include "tclInt.h"
@@ -2322,11 +2322,16 @@ ZlibTransformClose(
if (cd->outStream.avail_out != (unsigned) cd->outAllocated) {
if (Tcl_WriteRaw(cd->parent, cd->outBuffer,
cd->outAllocated - cd->outStream.avail_out) < 0) {
- /* TODO: is this the right way to do errors on close? */
+ /* TODO: is this the right way to do errors on close?
+ * Note: when close is called from FinalizeIOSubsystem
+ * then interp may be NULL
+ */
if (!TclInThreadExit()) {
- Tcl_AppendResult(interp,
+ if (interp) {
+ Tcl_AppendResult(interp,
"error while finalizing file: ",
Tcl_PosixError(interp), NULL);
+ }
}
result = TCL_ERROR;
break;
@@ -2377,8 +2382,11 @@ ZlibTransformInput(
return toRead - cd->inStream.avail_out;
}
if (e != Z_OK) {
- Tcl_SetChannelError(cd->parent,
- Tcl_NewStringObj(cd->inStream.msg, -1));
+ Tcl_Obj *errObj = Tcl_NewListObj(0, NULL);
+ Tcl_ListObjAppendElement(NULL, errObj,
+ Tcl_NewStringObj(cd->inStream.msg, -1));
+ Tcl_SetChannelError(cd->parent, errObj);
+ *errorCodePtr = EINVAL;
return -1;
}