Skip to content

Commit

Permalink
Proposed fix for [534172ff5b]: Crash in DeleteReflectedChannelMap (in…
Browse files Browse the repository at this point in the history
…troduced via tcllib 1.21)
  • Loading branch information
jan.nijtmans committed Feb 21, 2023
1 parent 2379b3a commit 4524e93
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions generic/tclIORChan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,8 +1128,8 @@ ReflectClose(
/*
* This call comes from TclFinalizeIOSystem. There are no
* interpreters, and therefore we cannot call upon the handler command
* anymore. Threading is irrelevant as well. We simply clean up all
* our C level data structures and leave the Tcl level to the other
* anymore. Threading is irrelevant as well. Simply clean up all
* the C level data structures and leave the Tcl level to the other
* finalization functions.
*/

Expand Down Expand Up @@ -2697,6 +2697,7 @@ DeleteThreadReflectedChannelMap(
Tcl_ThreadId self = Tcl_GetCurrentThread();
ReflectedChannelMap *rcmPtr; /* The map */
ForwardingResult *resultPtr;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
(void)dummy;

/*
Expand Down Expand Up @@ -2777,6 +2778,7 @@ DeleteThreadReflectedChannelMap(
*/

rcmPtr = GetThreadReflectedChannelMap();
tsdPtr->rcmPtr = NULL;
for (hPtr = Tcl_FirstHashEntry(&rcmPtr->map, &hSearch);
hPtr != NULL;
hPtr = Tcl_FirstHashEntry(&rcmPtr->map, &hSearch)) {
Expand Down Expand Up @@ -3083,10 +3085,10 @@ ForwardProc(
(paramPtr->seek.seekMode==SEEK_SET) ? "start" :
(paramPtr->seek.seekMode==SEEK_CUR) ? "current" : "end", -1);

Tcl_IncrRefCount(offObj);
Tcl_IncrRefCount(baseObj);
Tcl_IncrRefCount(offObj);
Tcl_IncrRefCount(baseObj);

Tcl_Preserve(rcPtr);
Tcl_Preserve(rcPtr);
if (InvokeTclMethod(rcPtr, METH_SEEK, offObj, baseObj, &resObj)!=TCL_OK){
ForwardSetObjError(paramPtr, resObj);
paramPtr->seek.offset = -1;
Expand Down

0 comments on commit 4524e93

Please sign in to comment.