Skip to content

Commit a03e6b0

Browse files
committed
Ensure the squirrel instance for native member function call actually has userpointer type
This prevents memory errors when incorrectly invoking native member functions from Squirrel.
1 parent cdafc12 commit a03e6b0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

sp/src/vscript/vscript_squirrel.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,10 @@ SQInteger function_stub(HSQUIRRELVM vm)
14251425
if (pFunc->m_flags & SF_MEMBER_FUNC)
14261426
{
14271427
SQUserPointer self;
1428-
sq_getinstanceup(vm, 1, &self, nullptr);
1428+
if (SQ_FAILED(sq_getinstanceup(vm, 1, &self, nullptr)))
1429+
{
1430+
return sq_throwerror(vm, "Expected userpointer");
1431+
}
14291432

14301433
if (!self)
14311434
{

0 commit comments

Comments
 (0)