[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/69: Fix type confusion in heap-numbers-equal? calls f
From: |
Andy Wingo |
Subject: |
[Guile-commits] 01/69: Fix type confusion in heap-numbers-equal? calls from VM |
Date: |
Fri, 7 Jan 2022 08:27:06 -0500 (EST) |
wingo pushed a commit to branch wip-inline-digits
in repository guile.
commit 0e505b7036611787c4ed1926c53cefc3ac308826
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Thu Jan 6 10:28:12 2022 +0100
Fix type confusion in heap-numbers-equal? calls from VM
When heap-numbers-equal? is called from eqv?, we have already ensured
that the both objects have the same heap type. However when called by
the VM, the precondition is just that both are heap numbers -- not
necessarily of the same type. Fix to add an additional check in
heap-numbers-equal?. Could cause crashers!
* libguile/eq.c (scm_i_heap_numbers_equal_p): Add additional check.
---
libguile/eq.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/libguile/eq.c b/libguile/eq.c
index bf18cda88..5d8c19a71 100644
--- a/libguile/eq.c
+++ b/libguile/eq.c
@@ -159,7 +159,14 @@ scm_i_fraction_equalp (SCM x, SCM y)
int
scm_i_heap_numbers_equal_p (SCM x, SCM y)
{
- if (SCM_IMP (x)) abort();
+ // Precondition: both X and Y are heap numbers.
+ if (!(SCM_HEAP_OBJECT_P (x) && SCM_HEAP_OBJECT_P (y)))
+ abort();
+ // eqv? already checks that the heap tags are the same, but we are
+ // also called by the VM, which only ensures that both values are
+ // numbers. So check tags here too.
+ if (SCM_CELL_TYPE (x) != SCM_CELL_TYPE (y))
+ return 0;
switch (SCM_TYP16 (x))
{
case scm_tc16_big:
- [Guile-commits] branch wip-inline-digits created (now a0d881f65), Andy Wingo, 2022/01/07
- [Guile-commits] 02/69: Add new integers.[ch], Andy Wingo, 2022/01/07
- [Guile-commits] 08/69: Implement ceiling-quotient with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 12/69: Implement truncate-remainder with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 15/69: Implement centered-remainder with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 17/69: Implement round-quotient with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 19/69: Implement round-divide with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 23/69: Implement scm_logior with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 24/69: Implement scm_logxor with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 01/69: Fix type confusion in heap-numbers-equal? calls from VM,
Andy Wingo <=
- [Guile-commits] 07/69: Implement floor-divide with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 03/69: Implement odd? and even? with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 10/69: Implement ceiling-divide with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 16/69: Implement centered-divide with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 20/69: Implement gcd with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 39/69: Clean up <, reimplement in terms of integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 40/69: positive?, negative? use integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 04/69: Implement abs with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 09/69: Implement ceiling-remainder with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 22/69: Implement scm_logand with new integer library, Andy Wingo, 2022/01/07