From 7b4fa860d2835a7f722879121538c43a82a554f8 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Mon, 22 Mar 2021 16:53:18 +0430 Subject: [PATCH] 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. --- Userland/Applications/Spreadsheet/Spreadsheet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 1654f98953..b3ad9f6c48 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/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();