Skip to content

Commit 81e36f3

Browse files
gh-96678: Fix UB of null pointer arithmetic (GH-96782)
Automerge-Triggered-By: GH:pablogsal
1 parent 6ba686d commit 81e36f3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix undefined behaviour in C code of null pointer arithmetic.

Parser/tokenizer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ tok_get(struct tok_state *tok, const char **p_start, const char **p_end)
15331533
} while (c == ' ' || c == '\t' || c == '\014');
15341534

15351535
/* Set start of current token */
1536-
tok->start = tok->cur - 1;
1536+
tok->start = tok->cur == NULL ? NULL : tok->cur - 1;
15371537

15381538
/* Skip comment, unless it's a type comment */
15391539
if (c == '#') {

0 commit comments

Comments
 (0)