LibKeyboard: Don't crash when file is empty

Just return empty map, like when file error occurs.
This commit is contained in:
Maciej Zygmanowski 2020-06-29 12:51:07 +02:00 committed by Andreas Kling
parent 53573f6fb1
commit 48cd26f12d
Notes: sideshowbarker 2024-07-19 05:19:48 +09:00

View file

@ -50,7 +50,8 @@ Optional<CharacterMapData> 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<u32> map = read_map(json, "map");