From 79a081ed4c70c084a2d9269611a95c1c3a17f9c4 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 21 Feb 2017 15:05:10 +0000 Subject: [PATCH] Added a note about integer division overflow --- runtime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime.c b/runtime.c index bcdd697f..b279ab43 100644 --- a/runtime.c +++ b/runtime.c @@ -2891,6 +2891,9 @@ object Cyc_fast_div(void *data, object ptr, object x, object y) { if (obj_is_int(x)){ if (obj_is_int(y)){ if (obj_obj2int(y) == 0) { goto divbyzero; } + // Overflow can occur if y = 0 || (x = 0x80000000 && y = -1) + // We already check for 0 above and the value of x above is a + // bignum, so no futher checks are required. z = obj_obj2int(x) / obj_obj2int(y); return obj_int2obj(z); } else if (is_object_type(y) && type_of(y) == double_tag) {