Skip to content

Commit e9895af

Browse files
committed
HPy: fix underflow in native fast-path for Long_AsUnsignedLong
1 parent 5f80671 commit e9895af

File tree

1 file changed

+5
-3
lines changed
  • graalpython/com.oracle.graal.python.jni/src

1 file changed

+5
-3
lines changed

graalpython/com.oracle.graal.python.jni/src/hpy_jni.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,12 @@ static long augment_Long_AsLong(HPyContext *ctx, HPy h) {
280280
static unsigned long augment_Long_AsUnsignedLong(HPyContext *ctx, HPy h) {
281281
uint64_t bits = toBits(h);
282282
if (isBoxedInt(bits)) {
283-
return unboxInt(bits);
284-
} else {
285-
return original_Long_AsUnsignedLong(ctx, h);
283+
int32_t unboxed = unboxInt(bits);
284+
if (unboxed >= 0) {
285+
return unboxed;
286+
}
286287
}
288+
return original_Long_AsUnsignedLong(ctx, h);
287289
}
288290

289291
static double augment_Long_AsDouble(HPyContext *ctx, HPy h) {

0 commit comments

Comments
 (0)