1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

sim65 close(-1) crash fix

test/val/constexpr.c relies on close(-1) to return -1 for some reason (comment says "abuse"), but on MSVC close(-1) is treated as a security issue and terminates the program instead of returning -1
simulating this desire for sim65, though constexpr.c may also warrant a review
This commit is contained in:
bbbradsmith 2023-05-05 21:46:11 -04:00
parent f2e7609046
commit 773716c32a

View File

@ -242,7 +242,15 @@ static void PVClose (CPURegs* Regs)
Print (stderr, 2, "PVClose ($%04X)\n", FD);
RetVal = close (FD);
if (FD != 0xFFFF) {
RetVal = close (FD);
} else {
/* test/val/constexpr.c "abuses" close, expecting close(-1) to return -1.
** This behaviour is not the same on all target platforms.
** MSVC's close treats it as a fatal error instead and terminates.
*/
RetVal = 0xFFFF;
}
SetAX (Regs, RetVal);
}