You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anyway, a quite serious bug is when one tries to iterate over a empty container (array or object), which results in a segmentation fault due to a 0x0 this pointer. I fixed this by changing the iterator constructors to check if the container is empty, and in that case set the “object_” pointer to a nullptr.
The proposed code fix:
json::const_iterator::const_iterator(const json* j) : object_(j)
{
if (object_ != nullptr)
{
if (object_->type_ == value_type::array)
{
if (object_->empty())
// Explicit empty check added
{
object_ = nullptr;
}
else
{
vi_ = newarray_t::const_iterator(object_->value_.array->begin());
}
}
elseif (object_->type_ == value_type::object)
// *else if* is mandatory since the previous
{
// block can set pointer to nullptr!if (object_->empty())
// Explicit empty check added
{
object_ = nullptr;
}
else
{
oi_ = newobject_t::const_iterator(object_->value_.object->begin());
}
}
}
}
The text was updated successfully, but these errors were encountered:
From an email:
The proposed code fix:
The text was updated successfully, but these errors were encountered: