From 57a35bf01ba2efa0c6b5bed2e549958e80596115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Wed, 25 May 2016 01:02:05 +0200 Subject: [PATCH] Don't crash on functions declared inside other functions Declaring a local variable inside any function works the same way as declaring it in top-level scope, which gets a bit weird if done inside a function inside a constant proplist, but is at least consistent. Thanks to Flinti for reporting this. --- src/script/C4AulParse.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/script/C4AulParse.cpp b/src/script/C4AulParse.cpp index 205d2aad9..e3ec03143 100644 --- a/src/script/C4AulParse.cpp +++ b/src/script/C4AulParse.cpp @@ -2175,6 +2175,7 @@ C4Value C4AulParse::Parse_ConstExpression(C4PropListStatic * parent, C4String * throw C4AulParseError(this, "global functions must be declared with 'global func'"); if (!Name) throw C4AulParseError(this, "functions must have a name"); + C4AulScriptFunc * prev_Fn = Fn; if (Type == PREPARSER) { Fn = new C4AulScriptFunc(parent, pOrgScript, Name ? Name->GetCStr() : NULL, SPos); @@ -2192,6 +2193,7 @@ C4Value C4AulParse::Parse_ConstExpression(C4PropListStatic * parent, C4String * Store_Const(parent, Name, r); Shift(); Parse_FuncBody(); + Fn = prev_Fn; } else {