Hold a reference to the temporary proplist used in case of script errors

The parser does not know whether the constant proplist it is about to fill
is missing because it was overwritten by a later local/constant, or because
the preparser was interrupted by a script error and didn't store its
proplist. Thus, the parser cannot simply give up at that point, and in
order to keep things simple it creates a throwaway proplist. This proplist
was thrown away too soon, though.

Thanks to Zapper for the testcase.

Conflicts:
	src/script/C4AulParse.cpp
stable-5.3
Günther Brammer 2013-02-12 01:11:31 +01:00 committed by Armin Burgmeier
parent 14f52ac5ce
commit 4ff7d3c8c9
3 changed files with 31 additions and 2 deletions

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,28 @@
local MENU =
{
left =
{
Wdt = 500,
title =
{
Wdt = 500,
Decoration = GUI_MenuDeco
}
},
right =
{
X = 500,
objects =
{
o1 = {Symbol = Rock, X = [0, 50], Y = [0, 40], Wdt = [0, 50 ERROR HERE! 64], Hgt=[0, 40 + 64]},
o2 = {Symbol = Gold, X = [500, 50 - 32], Y = [500, 40 - 32], Wdt = [500, 50 +32], Hgt = [500, 40 + 32]},
o3 = {Symbol = Wood, X = [1000, -64], Y = [1000, -64], Wdt = [1000, 0], Hgt = [500, 0]},
},
text =
{
Y = [1000, -300],
Hgt = 1000
}
}
};

View File

@ -1948,6 +1948,7 @@ void C4AulParse::Parse_PropList()
C4Value C4AulParse::Parse_ConstPropList(const C4PropListStatic * parent, C4String * Name)
{
C4Value v;
if (!Name)
throw new C4AulParseError(this, "a static proplist is not allowed to be anonymous");
C4PropListStatic * p;
@ -1957,7 +1958,6 @@ C4Value C4AulParse::Parse_ConstPropList(const C4PropListStatic * parent, C4Strin
}
else
{
C4Value v;
bool r;
if (parent)
r = parent->GetPropertyByS(Name, &v);
@ -1966,7 +1966,7 @@ C4Value C4AulParse::Parse_ConstPropList(const C4PropListStatic * parent, C4Strin
if (!r || !v.getPropList())
{
// the proplist couldn't be parsed or was overwritten by a later constant.
// create a temporary replacement
// create a temporary replacement, make v hold the reference to it for now
v.SetPropList(C4PropList::NewAnon(NULL, parent, Name));
}
p = v.getPropList()->IsStatic();