Skip to content
Tcl Source Code View Ticket
Login

View Ticket

pointer arithmetic using NULL in InitArgsAndLocals()

Closed / Fixed6cb3db4965ada9d88799c6a652534499bfc9b4a7Created 5 years agoUpdated 5 years ago
Descriptionwiki2021-12-28 23:51:25
UBSan -fsanitize=pointer-overflow error during test event-11.8:
tcl/generic/tclProc.c:1431:30: runtime error: applying zero offset to null pointer

Using a ternary expression avoids the error:

diff --git generic/tclProc.c generic/tclProc.c
index 642294cd8..1bd7361b1 100644
--- generic/tclProc.c
+++ generic/tclProc.c
@@ -1428,7 +1428,7 @@ InitArgsAndLocals(
     numArgs = procPtr->numArgs;
     argCt = framePtr->objc - skip;	/* Set it to the number of args to the
 					 * procedure. */
-    argObjs = framePtr->objv + skip;
+    argObjs = framePtr->objv ? framePtr->objv + skip : NULL;
     if (numArgs == 0) {
 	if (argCt) {
 	    goto incorrectArgs;
Referenced by1
  • 17a4e01dd3Fix [6cb3db4965]: pointer arithmetic using NULL in InitArgsAndLocals() check-in2022-01-13 11:46:50
jan.nijtmanswiki2022-01-13 11:49:48

Fixed [here] (slightly different) . Thanks for the report!

Log in (anonymous is fine) to add a comment.