From 48cd26f12d4970108ef68586322518c6e357c4d9 Mon Sep 17 00:00:00 2001 From: Maciej Zygmanowski Date: Mon, 29 Jun 2020 12:51:07 +0200 Subject: [PATCH] LibKeyboard: Don't crash when file is empty Just return empty map, like when file error occurs. --- Libraries/LibKeyboard/CharacterMapFile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/LibKeyboard/CharacterMapFile.cpp b/Libraries/LibKeyboard/CharacterMapFile.cpp index f9ff37a8fc..40db21b025 100644 --- a/Libraries/LibKeyboard/CharacterMapFile.cpp +++ b/Libraries/LibKeyboard/CharacterMapFile.cpp @@ -50,7 +50,8 @@ Optional CharacterMapFile::load_from_file(const String& file_n auto file_contents = file->read_all(); auto json_result = JsonValue::from_string(file_contents); - ASSERT(json_result.has_value()); + if (!json_result.has_value()) + return {}; auto json = json_result.value().as_object(); Vector map = read_map(json, "map");