diff options
author | Damien George <damien.p.george@gmail.com> | 2015-10-01 22:48:48 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-10-01 22:48:48 +0100 |
commit | e5635f4ab3d0fd00dd3951865fea82003205dae1 (patch) | |
tree | 9a1de95044325db1d35f071148358ca87c0ba239 /py/compile.c | |
parent | 2065373f67b126edfc3e0f2519aaad0956902c14 (diff) |
py: Catch all cases of integer (big and small) division by zero.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/py/compile.c b/py/compile.c index e00af60ad..797d7a95e 100644 --- a/py/compile.c +++ b/py/compile.c @@ -293,7 +293,9 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m // pass } else if (MP_PARSE_NODE_IS_TOKEN_KIND(pns->nodes[1], MP_TOKEN_OP_PERCENT)) { // int%int - pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, mp_small_int_modulo(arg0, arg1)); + if (arg1 != 0) { + pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, mp_small_int_modulo(arg0, arg1)); + } } else { assert(MP_PARSE_NODE_IS_TOKEN_KIND(pns->nodes[1], MP_TOKEN_OP_DBL_SLASH)); // should be if (arg1 != 0) { |