summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-10-01 22:48:48 +0100
committerDamien George <damien.p.george@gmail.com>2015-10-01 22:48:48 +0100
commite5635f4ab3d0fd00dd3951865fea82003205dae1 (patch)
tree9a1de95044325db1d35f071148358ca87c0ba239 /py/runtime.c
parent2065373f67b126edfc3e0f2519aaad0956902c14 (diff)
py: Catch all cases of integer (big and small) division by zero.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 69ac7549b..98cde83e5 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -389,6 +389,9 @@ mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_MODULO:
case MP_BINARY_OP_INPLACE_MODULO: {
+ if (rhs_val == 0) {
+ goto zero_division;
+ }
lhs_val = mp_small_int_modulo(lhs_val, rhs_val);
break;
}