Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0dffcb3887289b1a424299f2e31fb6f92bcb33da
Ticket: 218873ffffffffffffffffffffffffffffffffff
Bug in TclRegisterLiteral()
User & Date: nobody on 2000-10-26 01:07:01
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 2496 Bug
    Version: 8.2b1
    SubmitDate: '1999-08-04'
    LastModified: '1999-08-04'
    Severity: LOW
    Status: Released
    Submitter: techsupp
    ChangedBy: hobbs
    OS: Other
    Machine: NA
    FixedDate: '1999-08-04'
    FixedInVersion: 8.2
    ClosedDate: '2000-10-25'
    
    
    Name:
    Peter Spjuth
    
    ObservedBehavior:
    In tclLiteral.c, line 271, in the function TclRegisterLiteral,
        the following can be found:
        
        if (TclLooksLikeInt(bytes, length)) {
            if (TclGetLong((Tcl_Interp *) NULL, bytes, &n) == TCL_OK) {
        TclFormatInt(buf, n);
        if (strcmp(bytes, buf) == 0) {
            objPtr->internalRep.longValue = n;
            objPtr->typePtr = &tclIntType;
        }
            }
        }
        
        This is supposed to detect integer literals and give them an
        integer internal representation from the start.
        In reality though, it don't seem to work.
        
        What I believe is a bug is using "bytes" in the calls to
        TclGetLong and strcmp, since the literal at "bytes" is not null
        terminated. Typically, "bytes" is within a string being parsed,
        making it important to always use "length".
        On the code lines above these, the literal string is copied to
        "objPtr" and, as far as I can see, the resulting string in
        "objPtr" becomes properly null terminated.
        Thus, using "objPtr->bytes" instead of "bytes" in those two calls
        feels like a better solution.
        
        I haven't found any way to detect this bug using standard Tcl.
        I have a thing called "info internalrep" which gives the
        internal representation for an object. I found it odd that
        "info internalrep 4" returned "int" and "info internalrep 5"
        did not, and that put me on the track for this bug.
        
        I have not made any patch for this, since I currently can't test it.
    
    
    
    This change has been made for 8.2b3 (GetLong and strcmp calls
    use the objPtr->bytes). 
    -- 08/04/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.2b1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "Bug in TclRegisterLiteral()"
  11. type changed to: "Bug"