summaryrefslogtreecommitdiffstats
path: root/generic/tclIORChan.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-05-09 13:19:30 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-05-09 13:19:30 (GMT)
commitd28769d37874fb207bec2ac0d3c8206c7ab566f8 (patch)
tree5f3e8c4f2ade224a0ae31459b7b3561f00cfcaaf /generic/tclIORChan.c
parent777fc1f403ce2dd7dcf46cc42a059b0fe6363882 (diff)
downloadtcl-d28769d37874fb207bec2ac0d3c8206c7ab566f8.zip
tcl-d28769d37874fb207bec2ac0d3c8206c7ab566f8.tar.gz
tcl-d28769d37874fb207bec2ac0d3c8206c7ab566f8.tar.bz2
Test iocmd-32.1 is not "impossible" but after writing it properly it
does segfault trying to use a deleted interp. Fixed.
Diffstat (limited to 'generic/tclIORChan.c')
-rw-r--r--generic/tclIORChan.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index 7630473..3107f9e 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -438,8 +438,8 @@ static const char *msg_write_nothing = "{write wrote nothing}";
static const char *msg_seek_beforestart = "{Tried to seek before origin}";
#ifdef TCL_THREADS
static const char *msg_send_originlost = "{Channel thread lost}";
-static const char *msg_send_dstlost = "{Owner lost}";
#endif /* TCL_THREADS */
+static const char *msg_send_dstlost = "{Owner lost}";
static const char *msg_dstlost = "-code 1 -level 0 -errorcode NONE -errorinfo {} -errorline 1 {Owner lost}";
/*
@@ -1302,6 +1302,7 @@ ReflectOutput(
/* ASSERT: rcPtr->mode & TCL_WRITABLE */
Tcl_Preserve(rcPtr);
+ Tcl_Preserve(rcPtr->interp);
bufObj = Tcl_NewByteArrayObj((unsigned char *) buf, toWrite);
Tcl_IncrRefCount(bufObj);
@@ -1318,6 +1319,14 @@ ReflectOutput(
goto invalid;
}
+ if (Tcl_InterpDeleted(rcPtr->interp)) {
+ /*
+ * The interp was destroyed during InvokeTclMethod().
+ */
+
+ SetChannelErrorStr(rcPtr->chan, msg_send_dstlost);
+ goto invalid;
+ }
if (Tcl_GetIntFromObj(rcPtr->interp, resObj, &written) != TCL_OK) {
Tcl_SetChannelError(rcPtr->chan, MarshallError(rcPtr->interp));
goto invalid;
@@ -1347,6 +1356,7 @@ ReflectOutput(
stop:
Tcl_DecrRefCount(bufObj);
Tcl_DecrRefCount(resObj); /* Remove reference held from invoke */
+ Tcl_Release(rcPtr->interp);
Tcl_Release(rcPtr);
return written;
invalid: