Skip to content

Commit eb9a1c0

Browse files
ZackerySpytzserhiy-storchaka
authored andcommitted
[2.7] bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833). (GH-8849)
(cherry picked from commit 3e26e42) Co-authored-by: Zackery Spytz <[email protected]>
1 parent 95f9e14 commit eb9a1c0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Parser/parsetok.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,12 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
189189

190190
#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
191191
#endif
192-
if (a >= tok->line_start)
192+
if (a != NULL && a >= tok->line_start) {
193193
col_offset = a - tok->line_start;
194-
else
194+
}
195+
else {
195196
col_offset = -1;
197+
}
196198

197199
if ((err_ret->error =
198200
PyParser_AddToken(ps, (int)type, str, tok->lineno, col_offset,

0 commit comments

Comments
 (0)