Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

[SqPlus] missing pops cause stack growing

Last post 02-25-2007, 5:01 AM by Katsuaki Kawachi. 2 replies.
Sort Posts: Previous Next
  •  02-20-2007, 5:54 AM 1748

    [SqPlus] missing pops cause stack growing

    Two SquirrelObject methods must pop values from stack, but they don't.

    BOOL SquirrelObject::Exists(const SQChar *key) const
    {
    BOOL ret = FALSE;
    if(GetSlot(key)) {
    ret = TRUE;
    sq_pop(SquirrelVM::_VM,1); //--- HERE
    }
    sq_pop(SquirrelVM::_VM,1);
    return ret;
    }


    BOOL SquirrelObject::SetDelegate(SquirrelObject &obj)
    {
    if (obj.GetType() == OT_TABLE ||
    obj.GetType() == OT_NULL) {
    switch(_o._type) {
    case OT_USERDATA:
    case OT_TABLE:
    sq_pushobject(SquirrelVM::_VM,_o);
    sq_pushobject(SquirrelVM::_VM,obj._o);
    if(SQ_SUCCEEDED(sq_setdelegate(SquirrelVM::_VM,-2)))
    {
    sq_pop(SquirrelVM::_VM, 1); //--- HERE
    return TRUE;
    }
    sq_pop(SquirrelVM::_VM, 1); //--- HERE
    break;
    }
    }
    return FALSE;
    }


    When pops are not performed, SQVM stack can grow to huge sizes
  •  02-20-2007, 6:22 AM 1749 in reply to 1748

    Re: [SqPlus] missing pops cause stack growing

    Also, SquirrelVM::RunScript must do sq_pop(_VM,2), not sq_pop(_VM,1)
  •  02-25-2007, 5:01 AM 1759 in reply to 1749

    Re: [SqPlus] missing pops cause stack growing

    Thank you for your patch.
    I apply the fix to sqplus on sourceforge.  The snapshot is
    now put on the wiki.  Please test it.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems