Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f625c5d424e5967960d40b1cec190236438e1fd0
Ticket: a3309d01dbb0f23c3cf717ace30d9663fa54735f
Leak in array when unsetting keys from a proc
User & Date: aspect on 2015-07-16 03:22:29
Changes

  1. icomment:
    The following patch seems to fix this issue without breaking existing tests.  It's a bit brutish - a more sensitive patch would more closely compare this bytecoded INST_UNSET_ARRAY code with ArrayUnsetCmd().
    
    Bug seems to have existed since 8.6.2, so I guess it's been in the bytecode all along.
    
    
    Index: generic/tclExecute.c
    ==================================================================
    --- generic/tclExecute.c
    +++ generic/tclExecute.c
    @@ -4178,11 +4178,11 @@
                     * No nasty traces and element exists, so we can proceed to
                     * unset it. Might still not exist though...
                     */
     
                    if (!TclIsVarUndefined(varPtr)) {
    -                   TclDecrRefCount(varPtr->value.objPtr);
    +                   TclPtrUnsetVar(interp, varPtr, arrayPtr, NULL, part2Ptr, flags, opnd);
                    } else if (flags & TCL_LEAVE_ERR_MSG) {
                        goto slowUnsetArray;
                    }
                    varPtr->value.objPtr = NULL;
                    TRACE_APPEND(("OK\n"));
    
  2. login: "aspect"
  3. mimetype: "text/plain"