Index: generic/tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.170
diff -u -r1.170 tclIO.c
--- generic/tclIO.c	9 Dec 2009 23:26:53 -0000	1.170
+++ generic/tclIO.c	20 Dec 2009 15:24:02 -0000
@@ -8687,16 +8687,22 @@
     }
     if (esPtr == NULL) {
 	esPtr = (EventScriptRecord *) ckalloc(sizeof(EventScriptRecord));
-	Tcl_CreateChannelHandler((Tcl_Channel) chanPtr, mask,
-		TclChannelEventScriptInvoker, esPtr);
 	esPtr->nextPtr = statePtr->scriptRecordPtr;
 	statePtr->scriptRecordPtr = esPtr;
+	esPtr->chanPtr = chanPtr;
+	esPtr->interp = interp;
+	esPtr->mask = mask;
+	Tcl_IncrRefCount(scriptPtr);
+	esPtr->scriptPtr = scriptPtr;
+	Tcl_CreateChannelHandler((Tcl_Channel) chanPtr, mask,
+		TclChannelEventScriptInvoker, esPtr);
+    } else {
+	esPtr->chanPtr = chanPtr;
+	esPtr->interp = interp;
+	esPtr->mask = mask;
+	Tcl_IncrRefCount(scriptPtr);
+	esPtr->scriptPtr = scriptPtr;
     }
-    esPtr->chanPtr = chanPtr;
-    esPtr->interp = interp;
-    esPtr->mask = mask;
-    Tcl_IncrRefCount(scriptPtr);
-    esPtr->scriptPtr = scriptPtr;
 }
 
 /*
