]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[2.7] bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833). (GH-8849)
authorZackery Spytz <zspytz@gmail.com>
Wed, 22 Aug 2018 05:54:17 +0000 (23:54 -0600)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 22 Aug 2018 05:54:17 +0000 (08:54 +0300)
(cherry picked from commit 3e26e42c905852394fa136f1cc564dac98b56166)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Parser/parsetok.c

index 3189873a7a3a0290146b195e2e3ad45e7893bd17..a5e922243c56bc79cf39cb9acb2dd97e7aee5635 100644 (file)
@@ -189,10 +189,12 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
 
 #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
 #endif
-        if (a >= tok->line_start)
+        if (a != NULL && a >= tok->line_start) {
             col_offset = a - tok->line_start;
-        else
+        }
+        else {
             col_offset = -1;
+        }
 
         if ((err_ret->error =
              PyParser_AddToken(ps, (int)type, str, tok->lineno, col_offset,