summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-08-21 03:35:46 (GMT)
committerGitHub <noreply@github.com>2018-08-21 03:35:46 (GMT)
commite496b2b57a7b6e2633b741b1d5a934a7004ea3da (patch)
tree248ae71bc2b10facb3be03c0d27fac40fb1ae5d7
parent92970ccf02a90130c0606ff2ef0d7112020411d0 (diff)
downloadcpython-e496b2b57a7b6e2633b741b1d5a934a7004ea3da.zip
cpython-e496b2b57a7b6e2633b741b1d5a934a7004ea3da.tar.gz
cpython-e496b2b57a7b6e2633b741b1d5a934a7004ea3da.tar.bz2
bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833)
(cherry picked from commit 3e26e42c905852394fa136f1cc564dac98b56166) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
-rw-r--r--Parser/parsetok.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index b9c9fe8..a1580e6 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -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,