From eead19918d0209f33f737ee0ef54286f64740e32 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Thu, 28 Aug 2025 16:42:08 +0200 Subject: [PATCH] Fix NULL comparision --- engine/memobj.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engine/memobj.c b/engine/memobj.c index 67ad126..c5f3880 100644 --- a/engine/memobj.c +++ b/engine/memobj.c @@ -1076,6 +1076,15 @@ PH7_PRIVATE sxi32 PH7_MemObjCmp(ph7_value *pObj1, ph7_value *pObj2, int bStrict, /* Combine flag together */ iComb = pObj1->nType | pObj2->nType; if(iComb & (MEMOBJ_NULL | MEMOBJ_RES | MEMOBJ_BOOL)) { + /* Explicitly handle NULL/VOID comparisons with numeric types */ + if ((pObj1->nType & (MEMOBJ_NULL | MEMOBJ_VOID)) || (pObj2->nType & (MEMOBJ_NULL | MEMOBJ_VOID))) { + /* Convert both operands to their numeric representation + * NULL/VOID will be converted to 0 by PH7_MemObjToNumeric */ + PH7_MemObjToNumeric(pObj1); + PH7_MemObjToNumeric(pObj2); + /* Jump to the numeric comparison section */ + goto Numeric; + } /* Convert to boolean: Keep in mind FALSE < TRUE */ if((pObj1->nType & MEMOBJ_BOOL) == 0) { PH7_MemObjToBool(pObj1);