summaryrefslogtreecommitdiff
path: root/Userland/Applications/Spreadsheet/Spreadsheet.cpp
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-03-18 21:07:51 +0330
committerAndreas Kling <kling@serenityos.org>2021-03-22 07:43:58 +0100
commitc1d67d6b17e959bd58a5dbcd04cab93b345e1500 (patch)
treea898b45c8d025e3d5f959976d91c4d91aa9ff645 /Userland/Applications/Spreadsheet/Spreadsheet.cpp
parent9f8d518e829b1c0b35258f5124c9ca77bd974c88 (diff)
downloadserenity-c1d67d6b17e959bd58a5dbcd04cab93b345e1500.zip
Spreadsheet: Don't assume that the 'cells' field is an object
It might be missing, or not be an object. Fixes #4821.
Diffstat (limited to 'Userland/Applications/Spreadsheet/Spreadsheet.cpp')
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
index 437941f884..d66f982d39 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
@@ -383,6 +383,10 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
auto rows = object.get("rows").to_u32(default_row_count);
auto columns = object.get("columns");
auto name = object.get("name").as_string_or("Sheet");
+ auto cells_value = object.get_or("cells", JsonObject {});
+ if (!cells_value.is_object())
+ return nullptr;
+ auto& cells = cells_value.as_object();
sheet->set_name(name);
@@ -402,7 +406,6 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
sheet->add_column();
}
- auto cells = object.get("cells").as_object();
auto json = sheet->interpreter().global_object().get("JSON");
auto& parse_function = json.as_object().get("parse").as_function();