From ad95e0e2c4840cff212be8c6fbc07cd561428413 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 29 Jun 2020 12:19:47 -0400 Subject: [PATCH] Issue #392 - Do not reference double as bignum Fixed copy-and-paste issue that could lead to crashes and undefined behavior. --- CHANGELOG.md | 1 + runtime.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16d5dc9a..bce04eef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Features Bug Fixes +- Fixed a bug in the oprimized numeric comparison operators when comparing a double with a bignum, that could lead to undefined behavior. - Fixed `make_empty_bytevector` and `make_c_opaque` parameters on `(cyclone foreign)`. ## 0.18 - June 8, 2020 diff --git a/runtime.c b/runtime.c index be64d352..00c379b7 100644 --- a/runtime.c +++ b/runtime.c @@ -1818,7 +1818,7 @@ object FUNC_FAST_OP(void *data, object x, object y) { \ } else if (tx == -1 && ty == bignum_tag) { \ return Cyc_bignum_cmp(BN_CMP, x, tx, y, ty) ? boolean_t : boolean_f; \ } else if (tx == double_tag && ty == bignum_tag) { \ - return (double_value(x)) OP mp_get_double(&bignum_value(x)) ? boolean_t : boolean_f; \ + return (double_value(x)) OP mp_get_double(&bignum_value(y)) ? boolean_t : boolean_f; \ } else if (tx == complex_num_tag && ty == complex_num_tag) { \ return ((complex_num_value(x)) == (complex_num_value(y))) ? boolean_t : boolean_f; \ } else if (tx == complex_num_tag && ty != complex_num_tag) { \