GothicKit / ZenKit

A re-implementation of file formats used by the early 2000's ZenGin
http://zk.gothickit.dev/
MIT License
45 stars 10 forks source link

Potential Bug: Stack is cleared after Daedalus function call #95

Closed lmichaelis closed 1 month ago

lmichaelis commented 1 month ago

There might be a problem with this code, if a Daedalus function is called from within an external, because the entire stack (including previous function's stacks) might be cleared:

https://github.com/GothicKit/ZenKit/blob/7121a33e809905d68a6d13b9eb9fa619f84ae2df/include/zenkit/DaedalusVm.hh#L153-L170

Instead, we should clear the stack up to the previous call frame (taking into account return values). There should also be an unsafe function to trigger this behaviour from C and wrappers.

lmichaelis commented 1 month ago

Fixed in f53a955 by properly counting stack size.