mirror of
https://github.com/cc65/cc65.git
synced 2025-08-16 12:27:49 +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:
@@ -242,7 +242,15 @@ static void PVClose (CPURegs* Regs)
|
|||||||
|
|
||||||
Print (stderr, 2, "PVClose ($%04X)\n", FD);
|
Print (stderr, 2, "PVClose ($%04X)\n", FD);
|
||||||
|
|
||||||
|
if (FD != 0xFFFF) {
|
||||||
RetVal = close (FD);
|
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);
|
SetAX (Regs, RetVal);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user