Overview
| Artifact ID: | 81b470b86e1f07c69b99a10b6ca44a94d016b878 |
|---|---|
| Ticket: | 1675116fffffffffffffffffffffffffffffffff
lsort crash |
| User & Date: | afredd on 2007-03-08 00:54:44 |
Changes
- icomment:
Logged In: YES user_id=1386588 Originator: NO Here's a fix. It simply does a Tcl_DuplicateObj of the input list and sorts that (but only for calls using -command since this is the only way to hit the problem). [PS try doing the given example using -indices. No crash, but some odd looking indexes!] --- tclCmdIL.c-orig2007-03-07 17:42:32.856819800 +0000 +++ tclCmdIL.c2007-03-07 17:47:05.580806000 +0000 @@ -4143,7 +4143,7 @@ int i, index, unique, indices; Tcl_Obj *resultPtr; int length; - Tcl_Obj *cmdPtr, **listObjPtrs; + Tcl_Obj *cmdPtr, *listPtr, **listObjPtrs; SortElement *elementArray; SortElement *elementPtr; SortInfo sortInfo;/* Information about this sort that needs to @@ -4302,9 +4302,14 @@ } Tcl_ListObjAppendElement(interp, newCommandPtr, Tcl_NewObj()); sortInfo.compareCmdPtr = newCommandPtr; +/* Fixes [SW#1675116] */ +listPtr = Tcl_DuplicateObj(objv[objc-1]); +Tcl_IncrRefCount(listPtr); + } else { +listPtr = objv[objc-1]; } - sortInfo.resultCode = Tcl_ListObjGetElements(interp, objv[objc-1], + sortInfo.resultCode = Tcl_ListObjGetElements(interp, listPtr, &length, &listObjPtrs); if (sortInfo.resultCode != TCL_OK || length <= 0) { goto done; @@ -4353,6 +4358,7 @@ done: if (sortInfo.sortMode == SORTMODE_COMMAND) { Tcl_DecrRefCount(sortInfo.compareCmdPtr); +Tcl_DecrRefCount(listPtr); sortInfo.compareCmdPtr = NULL; } if (sortInfo.indexc > 1) { - login: "afredd"
- mimetype: "text/plain"
- username: "afredd"