Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 83dec42e62157a8a5a36a3d3de45944479009a02
Ticket: 1366195fffffffffffffffffffffffffffffffff
Use TCL_DSTRING_STATIC_SIZE rather than assume size
User & Date: afredd on 2005-11-25 10:40:37
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    A nice easy one...
    
    On windows, if you redefine TCL_DSTRING_STATIC_SIZE to 
    be small (4!) then it crashes in 
    TclpGetEncodingNameFromEnvironment because it assumes 
    the DString buffer is large enough. I've not seen 
    anything stating a minimum size for this so assume 
    this is 'allowed'.
    
    Something like:
    
    TclpGetEncodingNameFromEnvironment(bufPtr)
        Tcl_DString *bufPtr;
    {
        Tcl_DStringInit(bufPtr);
    +#define MIN_DSTRING_LEN   (3 + TCL_INTEGER_SPACE)
    +#if TCL_DSTRING_STATIC_SIZE < MIN_DSTRING_LEN
    +    Tcl_DStringSetLength(bufPtr, MIN_DSTRING_LEN);
    +#endif
        wsprintfA(Tcl_DStringValue(bufPtr), "cp%d", GetACP
    ());
        return Tcl_DStringValue(bufPtr);
    }
    
    seems like the simplest fix, as not many people are 
    going to hit this problem.
    
    After hittng this problem i had a quick look for any 
    other potentially similar problems and saw this in 
    tclWinDde.c:
    
    #line 367
    Tcl_DStringSetLength(&dString,
     offset + TCL_INTEGER_SPACE);
    
    I think this should be:
    
    Tcl_DStringSetLength(&dString,
     Tcl_DStringLength(&dString) + offset + 
    TCL_INTEGER_SPACE);
    
    
    ...but again it's only a problem if 
    TCL_DSTRING_STATIC_SIZE is small.
    
  4. foundin changed to: "obsolete: 8.5a3"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "afredd"
  9. subsystem changed to: "None"
  10. title changed to: "win: if TCL_DSTRING_STATIC_SIZE is small => crash"
  11. type changed to: "RFE"