jtothebell / fake-08

A Pico-8 player/emulator for console homebrew
Other
583 stars 50 forks source link

Fix for stack issue in pico8_ord #147

Closed nckstwrt closed 2 years ago

nckstwrt commented 2 years ago

In pico8_ord (lpico8lib.c) we push the numbers on the stack with lua_pushnumber - but with long strings this can easily smash the min stack. So we should call lua_checkstack before pushing. So the code should read:

lua_checkstack(l, count); for(int i = 0; i < count; i++) { lua_pushnumber(l, uint8_t(s[n + i])); }

With this extra line in there picochill no longer crashes fake-08 (the gfx don't look quite right, but that's a separate issue I will look into) - but at least it runs without a seg fault :)

(I should really start doing pulls..... :) )

jtothebell commented 2 years ago

Another good find, thank you again. patched up the lua implementation per your description