]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96678: Fix UB of null pointer arithmetic (GH-96782)
authorMatthias Görgens <matthias.goergens@gmail.com>
Tue, 13 Sep 2022 13:14:35 +0000 (21:14 +0800)
committerGitHub <noreply@github.com>
Tue, 13 Sep 2022 13:14:35 +0000 (06:14 -0700)
Automerge-Triggered-By: GH:pablogsal
Misc/NEWS.d/next/Core and Builtins/2022-09-13-12-06-46.gh-issue-96678.NqGFyb.rst [new file with mode: 0644]
Parser/tokenizer.c

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 (file)
index 0000000..bdd33c8
--- /dev/null
@@ -0,0 +1 @@
+Fix undefined behaviour in C code of null pointer arithmetic.
index d16af89df555171f6f1e3a636bf3d9c0f254bcee..b3b11855f4effa64eef58bd9cafdb1e0ece317d7 100644 (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 == '#') {