summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-02-15 15:43:54 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-02-15 15:43:54 (GMT)
commit0db044ae28d427ebebd09c07b3d6212d3ee1357a (patch)
tree5b74b4315e52cdf2cb2377fe42806948a0f9b465 /generic
parent3e2f142b59552edeaa2a6bb5e4a5d31e076ae8d7 (diff)
downloadtcl-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')
-rw-r--r--generic/tclIO.c62
-rw-r--r--generic/tclIORChan.c5
-rw-r--r--generic/tclIOUtil.c6
3 files changed, 47 insertions, 26 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;
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index faaaca1..514f89e 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIORChan.c,v 1.12 2005/12/13 22:43:17 kennykb Exp $
+ * RCS: @(#) $Id: tclIORChan.c,v 1.13 2006/02/15 15:43:55 dgp Exp $
*/
#include <tclInt.h>
@@ -845,6 +845,9 @@ UnmarshallErrorResult(
if (Tcl_ListObjGetElements(interp, msgObj, &lc, &lv) != TCL_OK) {
Tcl_Panic("TclChanCaughtErrorBypass: Bad syntax of caught result");
}
+ if (interp == NULL) {
+ return;
+ }
explicitResult = lc & 1; /* Odd number of values? */
numOptions = lc - explicitResult;
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index c60cd8e..35cd59f 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.127 2005/12/15 04:08:33 das Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.128 2006/02/15 15:43:55 dgp Exp $
*/
#include "tclInt.h"
@@ -1906,7 +1906,9 @@ Tcl_PosixError(
msg = Tcl_ErrnoMsg(errno);
id = Tcl_ErrnoId();
- Tcl_SetErrorCode(interp, "POSIX", id, msg, NULL);
+ if (interp) {
+ Tcl_SetErrorCode(interp, "POSIX", id, msg, NULL);
+ }
return msg;
}