Skip to content

Commit d357f71

Browse files
gh-96678: Fix UB of null pointer arithmetic (GH-96782)
Automerge-Triggered-By: GH:pablogsal (cherry picked from commit 81e36f3) Co-authored-by: Matthias Görgens <matthias.goergens@gmail.com>
1 parent fbc768f commit d357f71

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed
Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ tok_get(struct tok_state *tok, const char **p_start, const char **p_end)
15301530
} while (c == ' ' || c == '\t' || c == '\014');
15311531

15321532
/* Set start of current token */
1533-
tok->start = tok->cur - 1;
1533+
tok->start = tok->cur == NULL ? NULL : tok->cur - 1;
15341534

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

0 commit comments

Comments
 (0)