mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-07-27 07:31:49 +03:00
Check type of Squirrel constructor_stub() instance
This prevents manual invocations of the native class constructor with an invalid value.
This commit is contained in:
parent
9c494b6eeb
commit
9c740a891e
@ -1562,15 +1562,23 @@ SQInteger constructor_stub(HSQUIRRELVM vm)
|
|||||||
Assert(pSquirrelVM);
|
Assert(pSquirrelVM);
|
||||||
|
|
||||||
sq_resetobject(&pSquirrelVM->lastError_);
|
sq_resetobject(&pSquirrelVM->lastError_);
|
||||||
|
|
||||||
void* instance = pClassDesc->m_pfnConstruct();
|
|
||||||
|
|
||||||
// expect construction to always succeed
|
|
||||||
Assert(sq_isnull(pSquirrelVM->lastError_));
|
|
||||||
|
|
||||||
{
|
{
|
||||||
SQUserPointer p;
|
SQUserPointer p;
|
||||||
sq_getinstanceup(vm, 1, &p, 0);
|
if (SQ_FAILED(sq_getinstanceup(vm, 1, &p, 0)))
|
||||||
|
{
|
||||||
|
return SQ_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!p)
|
||||||
|
{
|
||||||
|
return sq_throwerror(vm, "Accessed null instance");
|
||||||
|
}
|
||||||
|
|
||||||
|
void* instance = pClassDesc->m_pfnConstruct();
|
||||||
|
|
||||||
|
// expect construction to always succeed
|
||||||
|
Assert(sq_isnull(pSquirrelVM->lastError_));
|
||||||
|
|
||||||
new(p) ClassInstanceData(instance, pClassDesc, nullptr, true);
|
new(p) ClassInstanceData(instance, pClassDesc, nullptr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user