diff options
author | dgp <dgp@users.sourceforge.net> | 2006-02-15 15:43:54 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2006-02-15 15:43:54 (GMT) |
commit | 0db044ae28d427ebebd09c07b3d6212d3ee1357a (patch) | |
tree | 5b74b4315e52cdf2cb2377fe42806948a0f9b465 /generic/tclIO.c | |
parent | 3e2f142b59552edeaa2a6bb5e4a5d31e076ae8d7 (diff) | |
download | tcl-0db044ae28d427ebebd09c07b3d6212d3ee1357a.zip tcl-0db044ae28d427ebebd09c07b3d6212d3ee1357a.tar.gz tcl-0db044ae28d427ebebd09c07b3d6212d3ee1357a.tar.bz2 |
* generic/tclIO.c: Made several routines tolerant of
* generic/tclIORChan.c: interp == NULL arguments. [Bug 1380662]
* generic/tclIOUtil.c:
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 86a25f6..d5e2593 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.103 2005/12/13 22:43:17 kennykb Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.104 2006/02/15 15:43:55 dgp Exp $ */ #include "tclInt.h" @@ -1272,8 +1272,10 @@ Tcl_StackChannel( } if (statePtr == NULL) { - Tcl_AppendResult(interp, "couldn't find state for channel \"", - Tcl_GetChannelName(prevChan), "\"", NULL); + if (interp) { + Tcl_AppendResult(interp, "couldn't find state for channel \"", + Tcl_GetChannelName(prevChan), "\"", NULL); + } return (Tcl_Channel) NULL; } @@ -1291,9 +1293,11 @@ Tcl_StackChannel( */ if ((mask & (statePtr->flags & (TCL_READABLE | TCL_WRITABLE))) == 0) { - Tcl_AppendResult(interp, - "reading and writing both disallowed for channel \"", - Tcl_GetChannelName(prevChan), "\"", NULL); + if (interp) { + Tcl_AppendResult(interp, + "reading and writing both disallowed for channel \"", + Tcl_GetChannelName(prevChan), "\"", NULL); + } return (Tcl_Channel) NULL; } @@ -1312,8 +1316,10 @@ Tcl_StackChannel( if (Tcl_Flush((Tcl_Channel) prevChanPtr) != TCL_OK) { statePtr->csPtr = csPtr; - Tcl_AppendResult(interp, "could not flush channel \"", - Tcl_GetChannelName(prevChan), "\"", NULL); + if (interp) { + Tcl_AppendResult(interp, "could not flush channel \"", + Tcl_GetChannelName(prevChan), "\"", NULL); + } return (Tcl_Channel) NULL; } @@ -1462,7 +1468,7 @@ Tcl_UnstackChannel( * to the regular message if nothing was found in the * bypasses. */ - if (!TclChanCaughtErrorBypass(interp, chan)) { + if (!TclChanCaughtErrorBypass(interp, chan) && interp) { Tcl_AppendResult(interp, "could not flush channel \"", Tcl_GetChannelName((Tcl_Channel) chanPtr), "\"", NULL); @@ -2404,7 +2410,9 @@ CloseChannel( Tcl_DecrRefCount(statePtr->chanMsg); statePtr->chanMsg = NULL; } - Tcl_SetChannelErrorInterp(interp,statePtr->unreportedMsg); + if (interp) { + Tcl_SetChannelErrorInterp(interp,statePtr->unreportedMsg); + } } if (errorCode == 0) { errorCode = result; @@ -2736,8 +2744,10 @@ Tcl_Close( } if (statePtr->flags & CHANNEL_INCLOSE) { - Tcl_AppendResult(interp, "Illegal recursive call to close ", - "through close-handler of channel", NULL); + if (interp) { + Tcl_AppendResult(interp, "Illegal recursive call to close ", + "through close-handler of channel", NULL); + } return TCL_ERROR; } statePtr->flags |= CHANNEL_INCLOSE; @@ -7853,13 +7863,17 @@ TclCopyChannel( outStatePtr = outPtr->state; if (inStatePtr->csPtr) { - Tcl_AppendResult(interp, "channel \"", - Tcl_GetChannelName(inChan), "\" is busy", NULL); + if (interp) { + Tcl_AppendResult(interp, "channel \"", + Tcl_GetChannelName(inChan), "\" is busy", NULL); + } return TCL_ERROR; } if (outStatePtr->csPtr) { - Tcl_AppendResult(interp, "channel \"", - Tcl_GetChannelName(outChan), "\" is busy", NULL); + if (interp) { + Tcl_AppendResult(interp, "channel \"", + Tcl_GetChannelName(outChan), "\" is busy", NULL); + } return TCL_ERROR; } @@ -8165,7 +8179,7 @@ CopyData( */ 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 reference to the @@ -8189,12 +8203,14 @@ CopyData( Tcl_Release((ClientData) interp); } else { StopCopy(csPtr); - if (errObj) { - Tcl_SetObjResult(interp, errObj); - result = TCL_ERROR; - } else { - Tcl_ResetResult(interp); - Tcl_SetObjResult(interp, Tcl_NewIntObj(total)); + if (interp) { + if (errObj) { + Tcl_SetObjResult(interp, errObj); + result = TCL_ERROR; + } else { + Tcl_ResetResult(interp); + Tcl_SetObjResult(interp, Tcl_NewIntObj(total)); + } } } return result; |