mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibKeyboard: Don't crash when file is empty
Just return empty map, like when file error occurs.
This commit is contained in:
parent
53573f6fb1
commit
48cd26f12d
Notes:
sideshowbarker
2024-07-19 05:19:48 +09:00
Author: https://github.com/sppmacd 🔰
Commit: 48cd26f12d
Pull-request: https://github.com/SerenityOS/serenity/pull/2656
Reviewed-by: https://github.com/awesomekling
1 changed files with 2 additions and 1 deletions
|
@ -50,7 +50,8 @@ Optional<CharacterMapData> CharacterMapFile::load_from_file(const String& file_n
|
||||||
|
|
||||||
auto file_contents = file->read_all();
|
auto file_contents = file->read_all();
|
||||||
auto json_result = JsonValue::from_string(file_contents);
|
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();
|
auto json = json_result.value().as_object();
|
||||||
|
|
||||||
Vector<u32> map = read_map(json, "map");
|
Vector<u32> map = read_map(json, "map");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue