Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 724048be43bb4a1eaa5e6709680f323d288d798c1756fcd71e3c13c85bc5fb4f
Ticket: fba9c1fc1236944900ffcb4ac09ef7de44a98a6e
pointer arithmetic using NULL in PrintParse()
User & Date: chrstphrchvz on 2021-12-29 00:27:19
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    [https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks|UBSan <tt>-fsanitize=pointer-overflow</tt>] error during test parseExpr-1.1:
    
    <pre>
    <span style="font-weight:bold">tcl/generic/tclTest.c:3623:46: <span style="color:red">runtime error:</span> applying zero offset to null pointer</span>
    </pre>
    
    Using a ternary expression avoids the error:
    
    <pre>
    diff --git generic/tclTest.c generic/tclTest.c
    index 5774dfc16..203c2ca4b 100644
    --- generic/tclTest.c
    +++ generic/tclTest.c
    @@ -3596,7 +3596,9 @@ PrintParse(
     		Tcl_NewIntObj(tokenPtr->numComponents));
         }
         Tcl_ListObjAppendElement(NULL, objPtr,
    <span style="color:red">-	    Tcl_NewStringObj(parsePtr->commandStart + parsePtr->commandSize,</span>
    <span style="color:green">+	    Tcl_NewStringObj(parsePtr->commandStart
    +		    ? parsePtr->commandStart + parsePtr->commandSize
    +		    : NULL,</span>
     	    -1));
     }
    <span> </span>
    </pre>
    
  5. foundin changed to: "8.6.12"
  6. is_private changed to: "0"
  7. login: "chrstphrchvz"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "chrstphrchvz"
  13. subsystem changed to: "34. tcltest Package"
  14. title changed to: "pointer arithmetic using NULL in PrintParse()"
  15. type changed to: "Patch"