Overview
| Artifact ID: | 690a60b342ed05a8019f42cda3c43c19b9ced961 |
|---|---|
| Ticket: | 405998ffffffffffffffffffffffffffffffffff
Tcl_SetListObj fails reset obj properly |
| User & Date: | dgp on 2001-03-29 10:09:11 |
Changes
- icomment:
Logged In: YES user_id=80530 I'm re-opening this and attaching a small C program that demonstrates that this bug can cause segfaults. I think the contributed fix should be accepted. In segfault.c, after Tcl_SetListObj() returns, objPtr->bytes == tclEmptyStringRep, but objPtr->length != 0. Then Tcl_AppendToObj() calls SetStringFromAny() which writes to objPtr->bytes[objPtr->length], assuming that length has a value that makes this safe. Instead memory is corrupted. segfault.c has been written so the corrupted memory changes the value of refArray in tclPreserve.c so the next time Tcl_Preserve() is called => SIGSEGV! This *could* be fixed with a rather complicated fix to SetStringFromAny(), but the simple fix contributed here is the better choice. Also, everywhere else in the core when ->bytes is assigned to tclEmptyStringRep, ->length is also assigned to 0, even if ->typePtr == NULL, notably in Tcl_NewObj(). I don't see any reason why Tcl_SetListObj() should be exceptional.
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "dgp"