mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +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
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