AK: Disallow implicit pointer-to-boolean conversion in JsonValue

Similar to how LibJS and LibSQL used to behave, the boolean constructor
of JsonValue is currently allowing pointers to be used to construct a
boolean value. Explicitly disallow such construction.
This commit is contained in:
Timothy Flynn 2022-12-08 11:03:39 -05:00 committed by Andreas Kling
parent 174062e0c5
commit 63e2aa962d
2 changed files with 9 additions and 7 deletions

View file

@ -168,12 +168,6 @@ JsonValue::JsonValue(double value)
}
#endif
JsonValue::JsonValue(bool value)
: m_type(Type::Bool)
{
m_value.as_bool = value;
}
JsonValue::JsonValue(DeprecatedString const& value)
{
if (value.is_null()) {

View file

@ -55,12 +55,20 @@ public:
#if !defined(KERNEL)
JsonValue(double);
#endif
JsonValue(bool);
JsonValue(char const*);
#ifndef KERNEL
JsonValue(DeprecatedString const&);
#endif
JsonValue(StringView);
template<typename T>
requires(SameAs<RemoveCVReference<T>, bool>)
JsonValue(T value)
: m_type(Type::Bool)
, m_value { .as_bool = value }
{
}
JsonValue(JsonArray const&);
JsonValue(JsonObject const&);