]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 21 Aug 2018 03:35:46 +0000 (23:35 -0400)
committerGitHub <noreply@github.com>
Tue, 21 Aug 2018 03:35:46 +0000 (23:35 -0400)
(cherry picked from commit 3e26e42c905852394fa136f1cc564dac98b56166)

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

index b9c9fe8fa8c29e71626c8d56783c02faa236cf25..a1580e6751e4c692ee355208f79b91ac3d889fad 100644 (file)
@@ -252,11 +252,13 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
             }
         }
 #endif
-        if (a >= tok->line_start)
+        if (a != NULL && a >= tok->line_start) {
             col_offset = Py_SAFE_DOWNCAST(a - tok->line_start,
                                           intptr_t, int);
-        else
+        }
+        else {
             col_offset = -1;
+        }
 
         if ((err_ret->error =
              PyParser_AddToken(ps, (int)type, str,