From 80f97204cbc52ec21c876123a4e87433cbe5e9b7 Mon Sep 17 00:00:00 2001 From: Alex Denford SBL Date: Wed, 30 Oct 2024 14:41:49 -0700 Subject: [PATCH] Nan bug fix --- quickjs.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/quickjs.c b/quickjs.c index 642ae34..0e93fd2 100644 --- a/quickjs.c +++ b/quickjs.c @@ -14097,20 +14097,25 @@ static no_inline int js_relational_slow(JSContext *ctx, JSValue *sp, } else { d2 = JS_VALUE_GET_INT(op2); } - switch(op) { - case OP_lt: - res = (d1 < d2); /* if NaN return false */ - break; - case OP_lte: - res = (d1 <= d2); /* if NaN return false */ - break; - case OP_gt: - res = (d1 > d2); /* if NaN return false */ - break; - default: - case OP_gte: - res = (d1 >= d2); /* if NaN return false */ - break; + + if (isnan(d1) || isnan(d2)) { + res = FALSE; + } else { + switch(op) { + case OP_lt: + res = (d1 < d2); + break; + case OP_lte: + res = (d1 <= d2); + break; + case OP_gt: + res = (d1 > d2); + break; + default: + case OP_gte: + res = (d1 >= d2); + break; + } } } }