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

(cherry picked from commit 3e26e42c90)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
Miss Islington (bot) 2018-08-20 23:23:15 -04:00 committed by GitHub
parent d1f0ccc7e6
commit 985dcd49ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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,