diff options
author | Matthias Görgens <matthias.goergens@gmail.com> | 2022-09-13 13:14:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-13 13:14:35 (GMT) |
commit | 81e36f350b75d2ed2668825f7df6e059b57f859c (patch) | |
tree | 09e8ffe2f2bd49a1bab35663af671365ef693aee | |
parent | 6ba686d97fd6d2a2169696c6629f7de9482f52db (diff) | |
download | cpython-81e36f350b75d2ed2668825f7df6e059b57f859c.zip cpython-81e36f350b75d2ed2668825f7df6e059b57f859c.tar.gz cpython-81e36f350b75d2ed2668825f7df6e059b57f859c.tar.bz2 |
gh-96678: Fix UB of null pointer arithmetic (GH-96782)
Automerge-Triggered-By: GH:pablogsal
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2022-09-13-12-06-46.gh-issue-96678.NqGFyb.rst | 1 | ||||
-rw-r--r-- | Parser/tokenizer.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-09-13-12-06-46.gh-issue-96678.NqGFyb.rst b/Misc/NEWS.d/next/Core and Builtins/2022-09-13-12-06-46.gh-issue-96678.NqGFyb.rst new file mode 100644 index 0000000..bdd33c8 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-09-13-12-06-46.gh-issue-96678.NqGFyb.rst @@ -0,0 +1 @@ +Fix undefined behaviour in C code of null pointer arithmetic. diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index d16af89..b3b1185 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -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 == '#') { |