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

(cherry picked from commit 3e26e42c90)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
Zackery Spytz 2018-08-21 23:54:17 -06:00 committed by Serhiy Storchaka
parent 95f9e14e33
commit eb9a1c01d0
1 changed files with 4 additions and 2 deletions

View File

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