mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-20 17:17:13 +02:00
Fix bug in plugin caused by not popping the closure from the stack after calling it.
This would've caused the plugin to run out of stack memory eventually.
This commit is contained in:
@ -1506,7 +1506,7 @@ struct StackGuard
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
~StackGuard()
|
||||
{
|
||||
sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
|
||||
Restore();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1519,6 +1519,20 @@ struct StackGuard
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
StackGuard & operator = (StackGuard &&) = delete;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Restore the stack to what was known to be.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Restore() const
|
||||
{
|
||||
// Retrieve the new stack top
|
||||
const SQInteger top = sq_gettop(m_VM);
|
||||
// Did the stack size change?
|
||||
if (top > m_Top)
|
||||
{
|
||||
sq_pop(m_VM, top - m_Top); // Trim the stack
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
HSQUIRRELVM m_VM; ///< The VM where the stack should be restored.
|
||||
|
Reference in New Issue
Block a user