summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2005-11-18 19:38:37 (GMT)
committerhobbs <hobbs>2005-11-18 19:38:37 (GMT)
commit3ab2242ba8e613f075243e4baa3dc2e7406b6e62 (patch)
tree6155ef5a57f809f7a02eb2ecf161588f34f78b19 /generic/tclIO.c
parent0487721e381e7cc22be51ec6fdcd2b83dd629297 (diff)
downloadtcl-3ab2242ba8e613f075243e4baa3dc2e7406b6e62.zip
tcl-3ab2242ba8e613f075243e4baa3dc2e7406b6e62.tar.gz
tcl-3ab2242ba8e613f075243e4baa3dc2e7406b6e62.tar.bz2
* generic/tclIO.c (TclFinalizeIOSubsystem): preserve statePtr
until we netrieve next statePtr from it.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 606ec75..f77a1a4 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.101 2005/11/18 17:15:57 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.102 2005/11/18 19:38:38 hobbs Exp $
*/
#include "tclInt.h"
@@ -180,7 +180,7 @@ TclFinalizeIOSubsystem(void)
ChannelState *statePtr; /* state of channel stack */
for (statePtr = tsdPtr->firstCSPtr; statePtr != NULL;
- statePtr = nextCSPtr) {
+ statePtr = nextCSPtr) {
chanPtr = statePtr->topChanPtr;
/*
@@ -202,6 +202,11 @@ TclFinalizeIOSubsystem(void)
statePtr->refCount--;
}
+ /*
+ * Preserve statePtr from disappearing until we can get the
+ * nextCSPtr below.
+ */
+ Tcl_Preserve(statePtr);
if (statePtr->refCount <= 0) {
/*
* Close it only if the refcount indicates that the channel is not
@@ -210,7 +215,6 @@ TclFinalizeIOSubsystem(void)
*/
(void) Tcl_Close(NULL, (Tcl_Channel) chanPtr);
-
} else {
/*
* The refcount is greater than zero, so flush the channel.
@@ -240,10 +244,11 @@ TclFinalizeIOSubsystem(void)
statePtr->flags |= CHANNEL_DEAD;
}
/*
- * We look for the next pointer now in case we had one closed on up during
- * the current channel's closeproc. (eg: rechan extension). [PT]
+ * We look for the next pointer now in case we had one closed on up
+ * during the current channel's closeproc (eg: rechan extension)
*/
nextCSPtr = statePtr->nextCSPtr;
+ Tcl_Release(statePtr);
}
TclpFinalizePipes();
}