diff options
author | Zackery Spytz <zspytz@gmail.com> | 2018-08-21 23:54:17 -0600 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-08-22 08:54:17 +0300 |
commit | eb9a1c01d07309006ef5544da62ba813685bd098 (patch) | |
tree | 05e61fb07367498fd05faa13deae4d3294567b0e /Parser | |
parent | 95f9e14e33b713f35f5368acf7be56750bbdb5a8 (diff) | |
download | cpython-git-eb9a1c01d07309006ef5544da62ba813685bd098.tar.gz |
[2.7] bpo-34400: Fix more undefined behavior in parsetok.c (GH-8833). (GH-8849)
(cherry picked from commit 3e26e42c905852394fa136f1cc564dac98b56166)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/parsetok.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c index 3189873a7a..a5e922243c 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -189,10 +189,12 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD #endif - if (a >= tok->line_start) + if (a != NULL && a >= tok->line_start) { col_offset = a - tok->line_start; - else + } + else { col_offset = -1; + } if ((err_ret->error = PyParser_AddToken(ps, (int)type, str, tok->lineno, col_offset, |