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

Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit 81e36f350b)

Co-authored-by: Matthias Görgens <matthias.goergens@gmail.com>
This commit is contained in:
Miss Islington (bot) 2022-09-13 08:03:40 -07:00 committed by GitHub
parent bc337a7766
commit f2d7fa8839
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

@ -1542,7 +1542,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 == '#') {