mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-27 19:59:03 +00:00
LibGUI: Don't silently create a 0 UIDimension when the JSON is invalid
The function already can report an invalid JSON value for the dimension, so let's actually use that for when the number is too large or some other invalid JSON type, like an object or a boolean, was passed.
This commit is contained in:
parent
ea0ab87b88
commit
d385adf6bd
Notes:
sideshowbarker
2024-07-16 22:18:54 +09:00
Author: https://github.com/kleinesfilmroellchen
Commit: d385adf6bd
Pull-request: https://github.com/SerenityOS/serenity/pull/17373
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/BenWiederhake ✅
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/linusg
Reviewed-by: https://github.com/me-minus
Reviewed-by: https://github.com/timschumi
1 changed files with 3 additions and 2 deletions
|
@ -162,12 +162,13 @@ public:
|
|||
return UIDimension { SpecialDimension::Fit };
|
||||
else
|
||||
return {};
|
||||
} else {
|
||||
int value_int = value.to_i32();
|
||||
} else if (value.is_integer<i32>()) {
|
||||
auto value_int = value.as_integer<i32>();
|
||||
if (value_int < 0)
|
||||
return {};
|
||||
return UIDimension(value_int);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue