Skip to content

Commit 985dcd4

Browse files
bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833)
(cherry picked from commit 3e26e42) Co-authored-by: Zackery Spytz <[email protected]>
1 parent d1f0ccc commit 985dcd4

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
@@ -252,11 +252,13 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
252252
}
253253
}
254254
#endif
255-
if (a >= tok->line_start)
255+
if (a != NULL && a >= tok->line_start) {
256256
col_offset = Py_SAFE_DOWNCAST(a - tok->line_start,
257257
intptr_t, int);
258-
else
258+
}
259+
else {
259260
col_offset = -1;
261+
}
260262

261263
if ((err_ret->error =
262264
PyParser_AddToken(ps, (int)type, str,

0 commit comments

Comments
 (0)