mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-01-23 09:16:20 -08:00
Document bugfix: ScriptCall can overflow wScriptStack and crash
This commit is contained in:
parent
1b1b0ac6ea
commit
fe04acad7b
@ -1422,21 +1422,26 @@ This supports up to six entries.
|
||||
|
||||
## `ScriptCall` can overflow `wScriptStack` and crash
|
||||
|
||||
In [engine/overworld/scripting.asm](/engine/overworld/scripting.asm):
|
||||
**Fix:** Edit `ScriptCall` in [engine/overworld/scripting.asm](/engine/overworld/scripting.asm):
|
||||
|
||||
```asm
|
||||
```diff
|
||||
ScriptCall:
|
||||
; Bug: The script stack has a capacity of 5 scripts, yet there is
|
||||
; nothing to stop you from pushing a sixth script. The high part
|
||||
; of the script address can then be overwritten by modifications
|
||||
; to wScriptDelay, causing the script to return to the rst/interrupt
|
||||
; space.
|
||||
|
||||
-; Bug: The script stack has a capacity of 5 scripts, yet there is
|
||||
-; nothing to stop you from pushing a sixth script. The high part
|
||||
-; of the script address can then be overwritten by modifications
|
||||
-; to wScriptDelay, causing the script to return to the rst/interrupt
|
||||
-; space.
|
||||
-
|
||||
+ ld hl, wScriptStackSize
|
||||
+ ld a, [hl]
|
||||
+ cp 5
|
||||
+ ret nc
|
||||
push de
|
||||
ld hl, wScriptStackSize
|
||||
ld e, [hl]
|
||||
- ld hl, wScriptStackSize
|
||||
- ld e, [hl]
|
||||
inc [hl]
|
||||
ld d, $0
|
||||
+ ld e, a
|
||||
ld d, 0
|
||||
ld hl, wScriptStack
|
||||
add hl, de
|
||||
add hl, de
|
||||
@ -1457,8 +1462,6 @@ ScriptCall:
|
||||
ret
|
||||
```
|
||||
|
||||
*To do:* Fix this bug.
|
||||
|
||||
|
||||
## `LoadSpriteGFX` does not limit the capacity of `UsedSprites`
|
||||
|
||||
|
@ -1454,7 +1454,7 @@ ScriptCall:
|
||||
ld hl, wScriptStackSize
|
||||
ld e, [hl]
|
||||
inc [hl]
|
||||
ld d, $0
|
||||
ld d, 0
|
||||
ld hl, wScriptStack
|
||||
add hl, de
|
||||
add hl, de
|
||||
|
Loading…
x
Reference in New Issue
Block a user