1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 09:37:34 +00:00

Shell: Don't blindly dereference the result of Parser::parse()

It _may_ return nullptr if there's nothing to return.
Fixes #5691.
This commit is contained in:
AnotherTest 2021-03-08 10:59:32 +03:30 committed by Andreas Kling
parent 26c4cae77c
commit fb68aa1480

View file

@ -1582,7 +1582,11 @@ bool Shell::has_history_event(StringView source)
bool has_history_event { false };
} visitor;
Parser { source, true }.parse()->visit(visitor);
auto ast = Parser { source, true }.parse();
if (!ast)
return false;
ast->visit(visitor);
return visitor.has_history_event;
}