Check type of SQVector construction instance

This prevents manual invocations of the Vector.constructor with an
invalid value.
This commit is contained in:
Alexander 'z33ky' Hirsch 2025-06-23 20:49:23 +02:00
parent 681a75a6a7
commit 655679e7da

View File

@ -327,7 +327,16 @@ namespace SQVector
}
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");
}
new (p) Vector(x, y, z);
return 0;