Fix SIGSEV with malformed functions
This commit is contained in:
parent
8103099287
commit
18ffe00bc4
|
@ -148,13 +148,13 @@ namespace Porygon::Parser {
|
||||||
}
|
}
|
||||||
auto identifier = this->Next();
|
auto identifier = this->Next();
|
||||||
auto next = this->Next();
|
auto next = this->Next();
|
||||||
if (type->GetKind() != TokenKind::Identifier && !hasErrors) {
|
if (!hasErrors && type->GetKind() != TokenKind::Identifier) {
|
||||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, type->GetStartPosition(),
|
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, type->GetStartPosition(),
|
||||||
type->GetLength());
|
type->GetLength());
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (identifier->GetKind() != TokenKind::Identifier && !hasErrors) {
|
if (!hasErrors && identifier->GetKind() != TokenKind::Identifier) {
|
||||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::UnexpectedToken, identifier->GetStartPosition(),
|
||||||
identifier->GetLength());
|
identifier->GetLength());
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
|
|
|
@ -189,5 +189,14 @@ stringResult = add('foo', 'bar')
|
||||||
delete stringVar;
|
delete stringVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Malformed parameter logs error", "[integration]" ) {
|
||||||
|
Script* script = Script::Create(uR"(
|
||||||
|
function blockOwnCritical( move, target, hitNumber )
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
)");
|
||||||
|
REQUIRE(script->Diagnostics -> HasErrors());
|
||||||
|
delete script;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue