diff options
author | dgp <dgp@users.sourceforge.net> | 2006-02-15 16:04:26 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2006-02-15 16:04:26 (GMT) |
commit | 8a69941cbf07e009343850ef3a370bcc7adf4f7e (patch) | |
tree | 996e867cdf99793046a663a9c41ebe5fc8ff061a | |
parent | 2ee0284e217d46d0ed94cb877ea1fd72d5cd89ed (diff) | |
download | tcl-8a69941cbf07e009343850ef3a370bcc7adf4f7e.zip tcl-8a69941cbf07e009343850ef3a370bcc7adf4f7e.tar.gz tcl-8a69941cbf07e009343850ef3a370bcc7adf4f7e.tar.bz2 |
* generic/tclIO.c: Made several routines tolerant of
* generic/tclIOUtil.c: interp == NULL arguments. [Bug 1380662]
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclIO.c | 66 | ||||
-rw-r--r-- | generic/tclIOUtil.c | 6 |
3 files changed, 50 insertions, 27 deletions
@@ -1,3 +1,8 @@ +2006-02-15 Don Porter <dgp@users.sourceforge.net> + + * generic/tclIO.c: Made several routines tolerant of + * generic/tclIOUtil.c: interp == NULL arguments. [Bug 1380662] + 2006-02-09 Don Porter <dgp@users.sourceforge.net> * tests/main.test (Tcl_Main-6.7): Improved robustness of diff --git a/generic/tclIO.c b/generic/tclIO.c index e0cf01a..852af2b 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.61.2.17 2005/11/18 19:38:02 hobbs Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.61.2.18 2006/02/15 16:04:27 dgp Exp $ */ #include "tclInt.h" @@ -1310,8 +1310,10 @@ Tcl_StackChannel(interp, typePtr, instanceData, mask, prevChan) } if (statePtr == NULL) { - Tcl_AppendResult(interp, "couldn't find state for channel \"", - Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, "couldn't find state for channel \"", + Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + } return (Tcl_Channel) NULL; } @@ -1329,9 +1331,11 @@ Tcl_StackChannel(interp, typePtr, instanceData, mask, prevChan) */ if ((mask & (statePtr->flags & (TCL_READABLE | TCL_WRITABLE))) == 0) { - Tcl_AppendResult(interp, - "reading and writing both disallowed for channel \"", - Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, + "reading and writing both disallowed for channel \"", + Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + } return (Tcl_Channel) NULL; } @@ -1350,8 +1354,10 @@ Tcl_StackChannel(interp, typePtr, instanceData, mask, prevChan) if (Tcl_Flush((Tcl_Channel) prevChanPtr) != TCL_OK) { statePtr->csPtr = csPtr; - Tcl_AppendResult(interp, "could not flush channel \"", - Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, "could not flush channel \"", + Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + } return (Tcl_Channel) NULL; } @@ -1477,9 +1483,11 @@ Tcl_UnstackChannel (interp, chan) if (Tcl_Flush((Tcl_Channel) chanPtr) != TCL_OK) { statePtr->csPtr = csPtr; - Tcl_AppendResult(interp, "could not flush channel \"", - Tcl_GetChannelName((Tcl_Channel) chanPtr), "\"", - (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, "could not flush channel \"", + Tcl_GetChannelName((Tcl_Channel) chanPtr), "\"", + (char *) NULL); + } return TCL_ERROR; } @@ -2562,9 +2570,11 @@ Tcl_Close(interp, chan) } if (statePtr->flags & CHANNEL_INCLOSE) { - Tcl_AppendResult(interp, - "Illegal recursive call to close through close-handler of channel", - (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, + "Illegal recursive call to close through close-handler of channel", + (char *) NULL); + } return TCL_ERROR; } statePtr->flags |= CHANNEL_INCLOSE; @@ -7574,13 +7584,17 @@ TclCopyChannel(interp, inChan, outChan, toRead, cmdPtr) outStatePtr = outPtr->state; if (inStatePtr->csPtr) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", - Tcl_GetChannelName(inChan), "\" is busy", NULL); + if (interp) { + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", + Tcl_GetChannelName(inChan), "\" is busy", NULL); + } return TCL_ERROR; } if (outStatePtr->csPtr) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", - Tcl_GetChannelName(outChan), "\" is busy", NULL); + if (interp) { + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", + Tcl_GetChannelName(outChan), "\" is busy", NULL); + } return TCL_ERROR; } @@ -7882,7 +7896,7 @@ CopyData(csPtr, mask) */ total = csPtr->total; - if (cmdPtr) { + if (cmdPtr && interp) { /* * Get a private copy of the command so we can mutate it * by adding arguments. Note that StopCopy frees our saved @@ -7906,12 +7920,14 @@ CopyData(csPtr, mask) Tcl_Release((ClientData) interp); } else { StopCopy(csPtr); - if (errObj) { - Tcl_SetObjResult(interp, errObj); - result = TCL_ERROR; - } else { - Tcl_ResetResult(interp); - Tcl_SetIntObj(Tcl_GetObjResult(interp), total); + if (interp) { + if (errObj) { + Tcl_SetObjResult(interp, errObj); + result = TCL_ERROR; + } else { + Tcl_ResetResult(interp); + Tcl_SetIntObj(Tcl_GetObjResult(interp), total); + } } } return result; diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 5e0acbb..84c9161 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.25 2006/01/12 18:03:48 vasiljevic Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.26 2006/02/15 16:04:29 dgp Exp $ */ #include "tclInt.h" @@ -1864,7 +1864,9 @@ Tcl_PosixError(interp) msg = Tcl_ErrnoMsg(errno); id = Tcl_ErrnoId(); - Tcl_SetErrorCode(interp, "POSIX", id, msg, (char *) NULL); + if (interp) { + Tcl_SetErrorCode(interp, "POSIX", id, msg, (char *) NULL); + } return msg; } |