Subject: Make sure the ReflectedChannel struct is freed in the handler thread, where it was allocated. This constraint allows the struct to safely hold Tcl_Obj values, which has been convenient for storing callback commands.

From: dgp <[email-masked]>
Date: Thu, 24 Apr 2014 15:27:58 +0000

---
 generic/tclIORChan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index e462f61..94428bb 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -1145,6 +1145,7 @@ ReflectClose(
 	    if (result != TCL_OK) {
 		FreeReceivedError(&p);
 	    }
+	    return EOK;
 	}
 #endif
 
@@ -1169,8 +1170,6 @@ ReflectClose(
 
         Tcl_DeleteEvents(ReflectEventDelete, rcPtr);
 
-        Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel);
-
 	if (result != TCL_OK) {
 	    PassReceivedErrorInterp(interp, &p);
 	}
@@ -2903,6 +2902,7 @@ ForwardProc(
                 Tcl_GetChannelName(rcPtr->chan));
 	Tcl_DeleteHashEntry(hPtr);
 
+	Tcl_EventuallyFree(rcPtr, (Tcl_FreeProc *) FreeReflectedChannel);
 	break;
 
     case ForwardedInput: {
-- 
cgit v0.12