From 21b271d0e701d427cba0e3b25e5aea86370aff52 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 20 Aug 2018 21:11:40 -0600 Subject: [PATCH] [2.7] bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833). (cherry picked from commit 3e26e42c905852394fa136f1cc564dac98b56166) Co-authored-by: Zackery Spytz --- Parser/parsetok.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Parser/parsetok.c b/Parser/parsetok.c index 3189873a7a3a02..a5e922243c56bc 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -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,