diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-07-03 21:55:31 +1200 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-07-03 21:55:31 +1200 |
commit | 667734aa76f9194d4a8627a94c23598303cc7521 (patch) | |
tree | fdc9d3606b3ea042bba30ca6b4e257f88371cea5 /bedrock.js | |
parent | c205d8069270aeb8deda690210b27d3039ea232f (diff) | |
download | bedrock-js-667734aa76f9194d4a8627a94c23598303cc7521.zip |
Prevent error when stack overflows
Previously, the stack overflowing would cause the stack pointer to point
outside of the stack, which would cause an error in the stack printing
code.
Diffstat (limited to 'bedrock.js')
-rw-r--r-- | bedrock.js | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -405,7 +405,9 @@ function EmulatorElement(options) { emulator.updateStatePanel = function() { function renderStack(stack) { let string = ''; - for (let i=0; i<stack.p; i++) string += hex(stack.mem[i], 2) + ' '; + for (let i=0; i<stack.p && i<stack.mem.length; i++) { + string += hex(stack.mem[i], 2) + ' '; + } return string; } pcState.textContent = hex(br.p, 4); |