Fix malloc and realloc overflow

If user requests a size >= 65532, adding the heap admin size
overflows size. Fixes #2358.
This commit is contained in:
Colin Leroy-Mira
2024-01-15 20:30:20 +01:00
parent 57e65a6bf6
commit 3e01ac9b04
4 changed files with 121 additions and 4 deletions

View File

@@ -131,6 +131,7 @@ _malloc:
sta ptr1
bcc @L1
inc ptr1+1
beq OutOfHeapSpace ; if high byte's 0, we overflowed!
@L1: ldx ptr1+1
bne @L2
cmp #HEAP_MIN_BLOCKSIZE+1
@@ -336,4 +337,3 @@ RetUserPtr:
bcc @L9
inx
@L9: rts