mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
Do a check if a local variable exceeds the available stack space.
Windows stack is 1 MB so play it safe and allow 512 kb as max. stack space for a single function.
This commit is contained in:
parent
59dab44380
commit
ee6991e6d8
1 changed files with 9 additions and 0 deletions
|
@ -12640,6 +12640,15 @@ FxExpression *FxLocalVariableDeclaration::Resolve(FCompileContext &ctx)
|
||||||
if (ValueType->RegType == REGT_NIL && ValueType != TypeAuto)
|
if (ValueType->RegType == REGT_NIL && ValueType != TypeAuto)
|
||||||
{
|
{
|
||||||
auto sfunc = static_cast<VMScriptFunction *>(ctx.Function->Variants[0].Implementation);
|
auto sfunc = static_cast<VMScriptFunction *>(ctx.Function->Variants[0].Implementation);
|
||||||
|
|
||||||
|
const unsigned MAX_STACK_ALLOC = 512 * 1024; // Windows stack is 1 MB, but we cannot go up there without problems
|
||||||
|
if (uint64_t(ValueType->Size) + uint64_t(sfunc->ExtraSpace) > MAX_STACK_ALLOC)
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "%s exceeds max. allowed size of 512kb for local variables at variable %s", sfunc->Name.GetChars(), Name.GetChars());
|
||||||
|
delete this;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
StackOffset = sfunc->AllocExtraStack(ValueType);
|
StackOffset = sfunc->AllocExtraStack(ValueType);
|
||||||
|
|
||||||
if (Init != nullptr)
|
if (Init != nullptr)
|
||||||
|
|
Loading…
Reference in a new issue