Overview
| Artifact ID: | c8cd1e6eff4e097d9ca8a17120f601cc1194a6f8 |
|---|---|
| Ticket: | 1904432fffffffffffffffffffffffffffffffff
Tcl_DeleteCommandFromToken and NULL token |
| User & Date: | dkf on 2016-07-24 18:15:56 |
Changes
- assignee changed to: "dkf"
- closer changed to: "nobody"
- comment changed to:
I create a command with Tcl_CreateObjCommand and register a delete procedure. Creation of the object and deletion of the object work fine. However, if the object is deleted a second time, I get segfaults. The only way for this to happen is if the object's delete procedure is being called, which shouldn't be happening. After the initial call to Tcl_DeleteCommandFromToken, any subsequent call to Tcl_GetCommandFromObj for that object should have returned NULL, and Tcl_DeleteCommandFromToken, being called with a NULL token, should have returned -1. The following code does not work as intended when an attempt is made to delete an object more than once. Tcl_DeleteCommandFromToken(interp, Tcl_GetCommandFromObj(interp, objv[i])); The following code is required for this to work: if ((token = Tcl_GetCommandFromObj(interp, objv[i]))) { Tcl_DeleteCommandFromToken(interp, token); } I believe that the desired result for Tcl_DeleteCommandFromToken, when called with a NULL token, should be to return -1, per the documentation. - icomment:
Might be worth fixing this according to the principle of <i>Do Nothing, Gracefully</i>.
- login: "dkf"
- mimetype: "text/html"
- severity changed to: "Minor"
- username: "dkf"