Skip to content

Commit

Permalink
bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackerySpytz authored and benjaminp committed Aug 21, 2018
1 parent cdbf50c commit 3e26e42
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Parser/parsetok.c
Expand Up @@ -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,
Expand Down

0 comments on commit 3e26e42

Please sign in to comment.