Overview
| Artifact ID: | a4f5d36e7fbb4d3dd68b3001c6f7285424aac890 |
|---|---|
| Ticket: | 3598580fffffffffffffffffffffffffffffffff
Tcl_ListObjReplace may release deleted elements too early |
| User & Date: | nijtmans on 2012-12-29 16:29:08 |
Changes
- icomment:
Let me respectfully disagree with your diagnostics that there is no bug here. The Tcl_ListObjReplace is expected to be fire-and-forget: when the objP object is not Tcl_IncRefCount'ed means that after the Tcl_ListObjReplace call this object is no longer used by the caller. In this case, that's true, so the caller should not need to increment the refCount. Yes, the example code is meaningless, but valid. From the documentation cannot be derived that the refcount should be incremented before the Tcl_ListObjReplace call, and decremented immediately after. The only thing my patch does is do the increment before the decrement, as suggested by Ashok, nothing else changed. I now corrected the escape path as well, restoring the refcounts as they were. Extreme care should be taken doing this in any 8.x releases, but with 4 pair of eyes focussed on this bug and all existing test-cases as back-up, I think this change should be fine. I am trying to turn this into a test-case for the test suite, but that's not finished yet.
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"