From c0cf078d78e30932c31a77913cf37ba3c2034732 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 16 Aug 2024 23:02:32 +0200 Subject: [PATCH] IARV64 results need to be checked for 0x7FFFF000 When MEMLIMIT is reached, IARV64 GETSTOR returns 0x7FFFF000; this conditions needs to be checked before memsetting. Fixes: #474 Signed-off-by: Irek Fakhrutdinov --- CHANGELOG.md | 1 + c/alloc.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1715d0120..ec15e6721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## `3.0.0` - Add support for LE 64-bit in isgenq.c (#422). +- Bugfix: IARV64 results must be checked for 0x7FFFF000 (#474) ## `2.17.0` - Fixed `xplatform.loadFileUTF8` when trying to open nonexistent file (#454) diff --git a/c/alloc.c b/c/alloc.c index 33742901a..b75b2fecf 100644 --- a/c/alloc.c +++ b/c/alloc.c @@ -181,7 +181,12 @@ static char* __ptr64 getmain64(long long sizeInMegabytes, int *returnCode, int * if (returnCode) *returnCode = macroRetCode; if (reasonCode) *reasonCode = macroResCode; - + + // IARV64 returns 0x7FFFF000 when MEMLIMIT is reached + if (data == (void *)0x7FFFF000) { + data = NULL; + } + return data; } @@ -202,7 +207,12 @@ static char* __ptr64 getmain64ByToken(long long sizeInMegabytes, long long token if (returnCode) *returnCode = macroRetCode; if (reasonCode) *reasonCode = macroResCode; - + + // IARV64 returns 0x7FFFF000 when MEMLIMIT is reached + if (data == (void *)0x7FFFF000) { + data = NULL; + } + return data; }