Skip to content

Commit f2d7fa8

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 bc337a7 commit f2d7fa8

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
@@ -1542,7 +1542,7 @@ tok_get(struct tok_state *tok, const char **p_start, const char **p_end)
15421542
} while (c == ' ' || c == '\t' || c == '\014');
15431543

15441544
/* Set start of current token */
1545-
tok->start = tok->cur - 1;
1545+
tok->start = tok->cur == NULL ? NULL : tok->cur - 1;
15461546

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

0 commit comments

Comments
 (0)