gh-96678: Fix UB of null pointer arithmetic (GH-96782)

Automerge-Triggered-By: GH:pablogsal
This commit is contained in:
Matthias Görgens 2022-09-13 21:14:35 +08:00 committed by GitHub
parent 6ba686d97f
commit 81e36f350b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix undefined behaviour in C code of null pointer arithmetic.

View File

@ -1533,7 +1533,7 @@ tok_get(struct tok_state *tok, const char **p_start, const char **p_end)
} while (c == ' ' || c == '\t' || c == '\014');
/* Set start of current token */
tok->start = tok->cur - 1;
tok->start = tok->cur == NULL ? NULL : tok->cur - 1;
/* Skip comment, unless it's a type comment */
if (c == '#') {