summaryrefslogtreecommitdiffstats
path: root/generic/tclIOCmd.c
diff options
context:
space:
mode:
authorwelch <welch>1998-06-27 18:09:53 (GMT)
committerwelch <welch>1998-06-27 18:09:53 (GMT)
commite49b28cf440752d763d488c4673d081883e93033 (patch)
tree1215c0959e90294b37bd360985895f49e8cbea9f /generic/tclIOCmd.c
parent32e60ee1bab18f9b5441eeb97eadcf604af608ef (diff)
downloadtcl-e49b28cf440752d763d488c4673d081883e93033.zip
tcl-e49b28cf440752d763d488c4673d081883e93033.tar.gz
tcl-e49b28cf440752d763d488c4673d081883e93033.tar.bz2
plugin updates
Diffstat (limited to 'generic/tclIOCmd.c')
-rw-r--r--generic/tclIOCmd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index 5640b47..88a299a 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -1238,12 +1238,28 @@ AcceptCallbackProc(callbackData, chan, address, port)
TclFormatInt(portBuf, port);
Tcl_RegisterChannel(interp, chan);
+
+ /*
+ * Artificially bump the refcount to protect the channel from
+ * being deleted while the script is being evaluated.
+ */
+
+ Tcl_RegisterChannel((Tcl_Interp *) NULL, chan);
+
result = Tcl_VarEval(interp, script, " ", Tcl_GetChannelName(chan),
" ", address, " ", portBuf, (char *) NULL);
if (result != TCL_OK) {
Tcl_BackgroundError(interp);
Tcl_UnregisterChannel(interp, chan);
}
+
+ /*
+ * Decrement the artificially bumped refcount. After this it is
+ * not safe anymore to use "chan", because it may now be deleted.
+ */
+
+ Tcl_UnregisterChannel((Tcl_Interp *) NULL, chan);
+
Tcl_Release((ClientData) interp);
Tcl_Release((ClientData) script);
} else {