Skip to content

Commit ec9afb5

Browse files
committed
Fix VMTAGGED_INTEGER_WITHIN_RANGE_CHECK
- need to be sure that what I compare is a int64_t if it would be a size_t, the range check would fail - also update TAG_INTEGER under ADDITIONAL_ALLOCATION to match normal one Signed-off-by: Stefan Marr <[email protected]>
1 parent 5647ec2 commit ec9afb5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/vmobjects/ObjectFormats.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050

5151
#ifdef __GNUC__
5252
#define VMTAGGED_INTEGER_WITHIN_RANGE_CHECK(X) \
53-
((X) >= VMTAGGEDINTEGER_MIN && (X) <= VMTAGGEDINTEGER_MAX)
53+
((int64_t(X) >= VMTAGGEDINTEGER_MIN) && \
54+
(int64_t(X) <= VMTAGGEDINTEGER_MAX))
5455
#else
5556
__attribute__((always_inline)) inline bool VMTAGGED_INTEGER_WITHIN_RANGE_CHECK(
5657
int64_t X) {
@@ -65,7 +66,7 @@ __attribute__((always_inline)) inline bool VMTAGGED_INTEGER_WITHIN_RANGE_CHECK(
6566
#if ADDITIONAL_ALLOCATION
6667
#define TAG_INTEGER(X) \
6768
((VMTAGGED_INTEGER_WITHIN_RANGE_CHECK(X) && Universe::NewInteger(0)) \
68-
? ((vm_oop_t)(((X) << 1U) | 1U)) \
69+
? ((vm_oop_t)((((uintptr_t)(X)) << 1U) | 1U)) \
6970
: (Universe::NewBigIntegerFromInt(X)))
7071
#else
7172
#define TAG_INTEGER(X) \

0 commit comments

Comments
 (0)