Bladeren bron

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

It _may_ return nullptr if there's nothing to return.
Fixes #5691.
AnotherTest 4 jaren geleden
bovenliggende
commit
fb68aa1480
1 gewijzigde bestanden met toevoegingen van 5 en 1 verwijderingen
  1. 5 1
      Userland/Shell/Shell.cpp

+ 5 - 1
Userland/Shell/Shell.cpp

@@ -1582,7 +1582,11 @@ bool Shell::has_history_event(StringView source)
         bool has_history_event { false };
         bool has_history_event { false };
     } visitor;
     } 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;
     return visitor.has_history_event;
 }
 }