|
2000-10-26
| ||
| 08:22 | • Closed ticket [218457ffff]: Tcl_ForeachObjCmd bug in Tcl8.0p2 plus 4 other c... artifact: cc0cfad794 user: welch | |
| 01:00 | • New ticket [218457ffff]. artifact: 2fb355afb4 user: nobody | |
Tcl_ForeachObjCmd bug in Tcl8.0p2
Closed / Fixed218457ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:00:37
OriginalBugID: 605 Bug
Version: 8.0p2
SubmitDate: '1998-05-21'
LastModified: '1999-08-06'
Severity: SER
Status: Released
Submitter: hershey
ChangedBy: hobbs
OS: All
OSVersion: NA
Machine: NA
FixedDate: '1999-08-06'
FixedInVersion: 8.1.1
ClosedDate: '2000-10-25'
There is a object reference count problem in Tcl_ForeachObjCmd
in Tcl8.0p2. Tcl_ListObjGetElements does not increment the reference counts
on the objects, so storing the objects in arrays and using them
each time through the loop doesn't work. I tried incrementing the
reference counts but this didn't work either. What did work was
extracting the elements each time through the loop. Here is a patch.
I know this is of dubious worth because I didn't track down the exact
cause of the bug, but the reference count stuff is confusing and I
don't have time to sort it out.
John
*** tclCmdAH.c 1998/04/10 18:56:28 1.1
--- tclCmdAH.c 1998/04/13 22:39:26
***************
*** 1530,1554 ****
bodyPtr = argObjv[objc-1];
for (j = 0; j < maxj; j++) {
for (i = 0; i < numLists; i++) {
! /*
! * If a variable or value list object has been converted to
! * another kind of Tcl object, convert it back to a list object
! * and refetch the pointer to its element array.
! */
!
! if (argObjv[1+i*2]->typePtr != &tclListType) {
! result = Tcl_ListObjGetElements(interp, argObjv[1+i*2],
! &varcList[i], &varvList[i]);
! if (result != TCL_OK) {
! panic("Tcl_ForeachObjCmd: could not reconvert variable list %d to a
list object\n", i);
! }
}
! if (argObjv[2+i*2]->typePtr != &tclListType) {
! result = Tcl_ListObjGetElements(interp, argObjv[2+i*2],
&argcList[i], &argvList[i]);
! if (result != TCL_OK) {
! panic("Tcl_ForeachObjCmd: could not reconvert value list %d to a list
object\n", i);
! }
}
for (v = 0; v < varcList[i]; v++) {
--- 1530,1544 ----
bodyPtr = argObjv[objc-1];
for (j = 0; j < maxj; j++) {
for (i = 0; i < numLists; i++) {
! result = Tcl_ListObjGetElements(interp, argObjv[1+i*2],
! &varcList[i], &varvList[i]);
! if (result != TCL_OK) {
! panic("Tcl_ForeachObjCmd: could not reconvert variable list %d to a list
object\n", i);
}
! result = Tcl_ListObjGetElements(interp, argObjv[2+i*2],
&argcList[i], &argvList[i]);
! if (result != TCL_OK) {
! panic("Tcl_ForeachObjCmd: could not reconvert value list %d to a list
object\n", i);
}
for (v = 0; v < varcList[i]; v++) {
This has been fixed as of (or before) 8.1.
-- 08/06/1999 hobbs
welch Closed ticket [218457ffff].
[History diff]2000-10-26 08:22:17
Log in (anonymous is fine) to add a comment.