Pārlūkot izejas kodu

Spreadsheet: Check for parse errors after parsing the source

There won't be any parse errors before we actually try to parse
something.
Fixes input like "=1+" crashing the spreadsheet instead of just causing
an error in the cell.
AnotherTest 4 gadi atpakaļ
vecāks
revīzija
7b4fa860d2
1 mainītis faili ar 1 papildinājumiem un 1 dzēšanām
  1. 1 1
      Userland/Applications/Spreadsheet/Spreadsheet.cpp

+ 1 - 1
Userland/Applications/Spreadsheet/Spreadsheet.cpp

@@ -199,10 +199,10 @@ Sheet::ValueAndException Sheet::evaluate(const StringView& source, Cell* on_beha
     ScopeGuard clear_exception { [&] { interpreter().vm().clear_exception(); } };
 
     auto parser = JS::Parser(JS::Lexer(source));
+    auto program = parser.parse_program();
     if (parser.has_errors() || interpreter().exception())
         return { JS::js_undefined(), interpreter().exception() };
 
-    auto program = parser.parse_program();
     interpreter().run(global_object(), program);
     if (interpreter().exception()) {
         auto exc = interpreter().exception();