[Python-checkins] bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833)

Miss Islington (bot) webhook-mailer at python.org
Mon Aug 20 23:23:19 EDT 2018


https://github.com/python/cpython/commit/985dcd49cab44bba63ffebe413a9ef17b3da5fa7
commit: 985dcd49cab44bba63ffebe413a9ef17b3da5fa7
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-08-20T23:23:15-04:00
summary:

bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833)

(cherry picked from commit 3e26e42c905852394fa136f1cc564dac98b56166)

Co-authored-by: Zackery Spytz <zspytz at gmail.com>

files:
M Parser/parsetok.c

diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index b9c9fe8fa8c2..a1580e6751e4 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -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,



More information about the Python-checkins mailing list