mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +00:00
Fixed: the game could crash while resolving expressions in some places
This commit is contained in:
parent
4a859393fe
commit
73d0ed78fe
2 changed files with 40 additions and 17 deletions
|
@ -361,7 +361,10 @@ static void FinishThingdef()
|
|||
if (sfunc == NULL)
|
||||
{
|
||||
FCompileContext ctx(ti);
|
||||
dmg->Resolve(ctx);
|
||||
dmg = static_cast<FxDamageValue *>(dmg->Resolve(ctx));
|
||||
|
||||
if (dmg != nullptr)
|
||||
{
|
||||
VMFunctionBuilder buildit;
|
||||
buildit.Registers[REGT_POINTER].Get(1); // The self pointer
|
||||
dmg->Emit(&buildit);
|
||||
|
@ -372,6 +375,7 @@ static void FinishThingdef()
|
|||
// (which happens quite easily with inheritance).
|
||||
dmg->SetFunction(sfunc);
|
||||
}
|
||||
}
|
||||
def->Damage = sfunc;
|
||||
|
||||
if (dump != NULL && sfunc != NULL)
|
||||
|
|
|
@ -191,7 +191,12 @@ static void ParseConstant (FScanner &sc, PSymbolTable *symt, PClassActor *cls)
|
|||
FxExpression *expr = ParseExpression (sc, cls, true);
|
||||
sc.MustGetToken(';');
|
||||
|
||||
if (!expr->isConstant())
|
||||
if (expr == nullptr)
|
||||
{
|
||||
sc.ScriptMessage("Error while resolving constant definition");
|
||||
FScriptPosition::ErrorCounter++;
|
||||
}
|
||||
else if (!expr->isConstant())
|
||||
{
|
||||
sc.ScriptMessage("Constant definition is not a constant");
|
||||
FScriptPosition::ErrorCounter++;
|
||||
|
@ -247,6 +252,8 @@ static void ParseEnum (FScanner &sc, PSymbolTable *symt, PClassActor *cls)
|
|||
if (sc.CheckToken('='))
|
||||
{
|
||||
FxExpression *expr = ParseExpression (sc, cls, true);
|
||||
if (expr != nullptr)
|
||||
{
|
||||
if (!expr->isConstant())
|
||||
{
|
||||
sc.ScriptMessage("'%s' must be constant", symname.GetChars());
|
||||
|
@ -258,6 +265,12 @@ static void ParseEnum (FScanner &sc, PSymbolTable *symt, PClassActor *cls)
|
|||
}
|
||||
delete expr;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.ScriptMessage("Error while resolving expression of '%s'", symname.GetChars());
|
||||
FScriptPosition::ErrorCounter++;
|
||||
}
|
||||
}
|
||||
PSymbolConstNumeric *sym = new PSymbolConstNumeric(symname, TypeSInt32);
|
||||
sym->Value = currvalue;
|
||||
if (symt->AddSymbol (sym) == NULL)
|
||||
|
@ -568,7 +581,13 @@ static void ParseUserVariable (FScanner &sc, PSymbolTable *symt, PClassActor *cl
|
|||
if (sc.CheckToken('['))
|
||||
{
|
||||
FxExpression *expr = ParseExpression(sc, cls, true);
|
||||
if (!expr->isConstant())
|
||||
if (expr == nullptr)
|
||||
{
|
||||
sc.ScriptMessage("Error while resolving array size");
|
||||
FScriptPosition::ErrorCounter++;
|
||||
maxelems = 1;
|
||||
}
|
||||
else if (!expr->isConstant())
|
||||
{
|
||||
sc.ScriptMessage("Array size must be a constant");
|
||||
FScriptPosition::ErrorCounter++;
|
||||
|
|
Loading…
Reference in a new issue