mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-07-27 07:31:49 +03:00
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.
This commit is contained in:
parent
cdafc1278e
commit
c851fc9bfb
@ -1324,7 +1324,10 @@ SQInteger function_stub(HSQUIRRELVM vm)
|
|||||||
SQInteger top = sq_gettop(vm);
|
SQInteger top = sq_gettop(vm);
|
||||||
|
|
||||||
SQUserPointer userptr = nullptr;
|
SQUserPointer userptr = nullptr;
|
||||||
sq_getuserpointer(vm, top, &userptr);
|
if (SQ_FAILED(sq_getuserpointer(vm, top, &userptr)))
|
||||||
|
{
|
||||||
|
return sq_throwerror(vm, "Expected userpointer");
|
||||||
|
}
|
||||||
|
|
||||||
Assert(userptr);
|
Assert(userptr);
|
||||||
|
|
||||||
@ -1425,7 +1428,10 @@ SQInteger function_stub(HSQUIRRELVM vm)
|
|||||||
if (pFunc->m_flags & SF_MEMBER_FUNC)
|
if (pFunc->m_flags & SF_MEMBER_FUNC)
|
||||||
{
|
{
|
||||||
SQUserPointer self;
|
SQUserPointer self;
|
||||||
sq_getinstanceup(vm, 1, &self, nullptr);
|
if (SQ_FAILED(sq_getinstanceup(vm, 1, &self, 0)))
|
||||||
|
{
|
||||||
|
return sq_throwerror(vm, "Expected class userpointer");
|
||||||
|
}
|
||||||
|
|
||||||
if (!self)
|
if (!self)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user