1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:17:34 +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:
kleines Filmröllchen 2023-02-18 12:11:56 +01:00 committed by Jelle Raaijmakers
parent ea0ab87b88
commit d385adf6bd

View file

@ -162,12 +162,13 @@ public:
return UIDimension { SpecialDimension::Fit }; return UIDimension { SpecialDimension::Fit };
else else
return {}; return {};
} else { } else if (value.is_integer<i32>()) {
int value_int = value.to_i32(); auto value_int = value.as_integer<i32>();
if (value_int < 0) if (value_int < 0)
return {}; return {};
return UIDimension(value_int); return UIDimension(value_int);
} }
return {};
} }
private: private: