From fb68aa1480d40eaa8326b22d0add01ccee6ec470 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Mon, 8 Mar 2021 10:59:32 +0330 Subject: [PATCH] Shell: Don't blindly dereference the result of Parser::parse() It _may_ return nullptr if there's nothing to return. Fixes #5691. --- Userland/Shell/Shell.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 21672313e1..2273482d12 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -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; }