1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-03-02 01:40:22 +00:00

Additional check for bad stack offset calculation

Pointer difference calculations on an inappropriate stack pointer could
result in a negative offset, not just an offset that is too large to fit
in 16 bits.  Complain if either case occurs.
This commit is contained in:
Nick Briggs
2024-03-07 10:01:19 -08:00
parent 55591557b6
commit 939c23c03b

View File

@@ -63,8 +63,8 @@ static inline DLword StackOffsetFromNative(void *SAddr)
{
/* Stack offsets are expressed as an offset in DLwords from the stack base */
ptrdiff_t hoffset = (DLword *)SAddr - Stackspace;
if (hoffset > 0xffff) {
printf("Stack offset is too large: 0x%tx\n", hoffset);
if (hoffset > 0xffff || hoffset < 0) {
printf("Stack offset is out of range: 0x%tx\n", hoffset);
}
return (DLword)hoffset;
}