summaryrefslogtreecommitdiffhomepage
path: root/types.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2023-07-25 14:33:53 +0200
committerGitHub <noreply@github.com>2023-07-25 14:33:53 +0200
commitbb5eba4db8895d862038825b84d5b7a94ee5cbb0 (patch)
treeb1494c186a4c9634b25f7ffec53c129814be0d7a /types.c
parent4bee0efb49c7763f38be5d69eea90b2f11944793 (diff)
parent093684df07cee69a06deed665bbb0cb3eeaf3841 (diff)
Merge pull request #166 from jow-/fix-165
Fix 165
Diffstat (limited to 'types.c')
-rw-r--r--types.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/types.c b/types.c
index 5758f74..d601479 100644
--- a/types.c
+++ b/types.c
@@ -1998,7 +1998,7 @@ ucv_compare(int how, uc_value_t *v1, uc_value_t *v2, int *deltap)
uint64_t u1, u2;
int64_t n1, n2;
double d1, d2;
- int8_t delta;
+ int delta;
/* at least one operand is null and we compare for equality or inequality ... */
if ((!v1 || !v2) && (how == I_EQ || how == I_NE)) {
@@ -2015,7 +2015,12 @@ ucv_compare(int how, uc_value_t *v1, uc_value_t *v2, int *deltap)
/* ... both operands are of the same, non-scalar type... */
if (t1 == t2 && !ucv_is_scalar(v1)) {
/* ... compare memory addrs */
- delta = (intptr_t)v1 - (intptr_t)v2;
+ if ((uintptr_t)v1 == (uintptr_t)v2)
+ delta = 0;
+ else if ((uintptr_t)v1 < (uintptr_t)v2)
+ delta = -1;
+ else
+ delta = 1;
}
/* ... operands are of different type or at least one is scalar... */