Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: dd9ff02d7d1b960de65ab8d9afb8c3d6f377576d5e7aefaf79e213ff69266a96
Ticket: 14680527328fdcadb5e558c998621d28eb607db4
Changes to Tcl_GetByteArrayFromObj not correct?
User & Date: apnadkarni on 2023-09-25 18:06:30
Changes

  1. icomment:
    Along the same lines (but not part of same commit), in Tcl 9 the current definition of Stub 41 is 
    
    ```
    declare 41 {
        char *TclGetStringFromObj(Tcl_Obj *objPtr, void *lengthPtr)
    }
    ```
    
    However, TclGetStringFromObj **always** treats lengthPtr as an `int *`. Thus following a "conflict-free" merge from core-8-branch, the following fragment caused a crash.
    
    ```
    Tcl_Size len;
    const char *path = TclGetStringFromObj(normPathPtr, &len);
    ...
    path[len-1] = '\0';
    ```
    
    because only the low four bytes of `len` were updated by the TGSFO call.
    
    Either Stub 41 should be removed, or defined as taking an `int*` so that compiler will catch these errors. The way it is currently defined serves no utility afaict but I'm wary of changing it myself in case there is some use I don't see.
    
    Alternately, define it as taking an `Tcl_Size *` and name it as `Tcl_GetStringFromObj` replacing stub 651.
    
  2. login: "apnadkarni"
  3. mimetype: "text/plain"