Fix nullptr deref in Poco::JSON::Object (#2150)

This commit is contained in:
Conor Burgess 2018-02-09 16:15:26 +00:00 committed by Alex Fabijanic
parent d9bff00222
commit bdd0478ead
2 changed files with 5 additions and 4 deletions

View File

@ -346,8 +346,7 @@ inline bool Object::isArray(const std::string& key) const
inline bool Object::isArray(ConstIterator& it) const
{
const std::type_info& ti = it->second.type();
return it != _values.end() && (ti == typeid(Array::Ptr) || ti == typeid(Array));
return it != _values.end() && (it->second.type() == typeid(Array::Ptr) || it->second.type() == typeid(Array));
}
@ -367,8 +366,7 @@ inline bool Object::isObject(const std::string& key) const
inline bool Object::isObject(ConstIterator& it) const
{
const std::type_info& ti = it->second.type();
return it != _values.end() && (ti == typeid(Object::Ptr) || ti == typeid(Object));
return it != _values.end() && (it->second.type() == typeid(Object::Ptr) || it->second.type() == typeid(Object));
}

View File

@ -643,6 +643,9 @@ void JSONTest::testObjectProperty()
assert (object->isObject("test"));
assert (!object->isArray("test"));
assert (!object->isArray("nonExistentKey"));
assert (!object->isObject("nonExistentKey"));
Var test = object->get("test");
assert (test.type() == typeid(Object::Ptr));
Object::Ptr subObject = test.extract<Object::Ptr>();