From f106a1f0a2348f5765d277ac30b42e08eff99b98 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 9 Aug 2017 12:41:43 +0000 Subject: [PATCH] Issue #210 - Prevent divide-by-zero error --- CHANGELOG.md | 10 ++++++++++ runtime.c | 1 + 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5edbc1a1..e11f2145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## Next Release - TBD + +Features + +- Added SRFI 143 - Fixnums. + +Bug Fixes + +- Prevent `remainder` from crashing the runtime due to divide by zero. + ## 0.5.4 - August 3, 2017 Features diff --git a/runtime.c b/runtime.c index 1513deda..1bfc5b25 100644 --- a/runtime.c +++ b/runtime.c @@ -3367,6 +3367,7 @@ void Cyc_remainder(void *data, object cont, object num1, object num2) j = ((double_type *)num2)->value; } } + if (j == 0) { Cyc_rt_raise_msg(data, "Divide by zero"); } result = obj_int2obj(i % j); return_closcall1(data, cont, result); }