Commit e3caa27
authored
Skip loadExtRam when the buffer is empty (#74)
An empty Uint8Array is still truthy, so the constructor's
`if (extRamBuffer)` guard called loadExtRam even when there was no
save data to restore. For carts that don't advertise external RAM
(MBC5 with EXT_RAM_SIZE_NONE, ROM-only, etc.),
`_ext_ram_file_data_new` returns 0 and the wasm side then reads
from a null file-data ptr inside `_emulator_read_ext_ram`.
Sometimes that lands on valid wasm linear memory, sometimes it's
out of bounds depending on heap state from prior alloc/free
cycles — surfacing as an intermittent
"RuntimeError: memory access out of bounds" in long-running embed
scenarios that recreate the Emulator multiple times.
Tighten the guard to also require `extRamBuffer.byteLength > 0`.1 parent b5f718e commit e3caa27
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
0 commit comments