Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 61d36479b3a44958752cfc956e8fed2fe4780652
Ticket: 3202905fffffffffffffffffffffffffffffffff
Incorrect Tcl Interpreter Obj Result
User & Date: cjmcdonald on 2011-03-08 11:43:46
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    There is a problem with obj results returned from an
    interpreter. When the obj result is reset, a tclStringType
    internal rep can be left for an empty string.  This then
    gives inconsistent results for a new obj result.
    
    The attached example program objresult_example.c
    demonstrates the issue.
    
    The problem is in ResetObjResult in tclResult.c, where it is
    assumed that the obj result only needs to be reset if it is
    not an empty string. Changing this so that is always clears
    any internal rep fixes the problem.
    
    This patch is against the 8.5.9 release:
    
    *** tclResult.c.859     Wed Mar 24 15:31:48 2010
    --- tclResult.c Tue Mar  8 11:21:20 2011
    ***************
    *** 961,972 ****
            TclNewObj(objResultPtr);
            Tcl_IncrRefCount(objResultPtr);
            iPtr->objResultPtr = objResultPtr;
    !     } else if (objResultPtr->bytes != tclEmptyStringRep) {
    !       if (objResultPtr->bytes != NULL) {
    !           ckfree((char *) objResultPtr->bytes);
            }
    -       objResultPtr->bytes = tclEmptyStringRep;
    -       objResultPtr->length = 0;
            TclFreeIntRep(objResultPtr);
            objResultPtr->typePtr = NULL;
          }
    --- 961,974 ----
            TclNewObj(objResultPtr);
            Tcl_IncrRefCount(objResultPtr);
            iPtr->objResultPtr = objResultPtr;
    !     } else {
    !       if (objResultPtr->bytes != tclEmptyStringRep) {
    !           if (objResultPtr->bytes != NULL) {
    !               ckfree((char *) objResultPtr->bytes);
    !           }
    !           objResultPtr->bytes = tclEmptyStringRep;
    !           objResultPtr->length = 0;
            }
            TclFreeIntRep(objResultPtr);
            objResultPtr->typePtr = NULL;
          }
    
    
  4. foundin changed to: "obsolete: 8.5.9"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "cjmcdonald"
  10. subsystem changed to: "45. Parsing and Eval"
  11. title changed to: "Incorrect Tcl Interpreter Obj Result"
  12. type changed to: "Bug"