mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
🐛 fix bug in SAX callback parser
This commit is contained in:
@ -4881,7 +4881,7 @@ class json_sax_dom_parser
|
||||
|
||||
bool binary(binary_t& val)
|
||||
{
|
||||
handle_binary(val);
|
||||
handle_value(BasicJsonType::binary_array(std::move(val)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4994,36 +4994,6 @@ class json_sax_dom_parser
|
||||
return object_element;
|
||||
}
|
||||
|
||||
/*!
|
||||
@invariant If the ref stack is empty, then the passed value will be the new
|
||||
root.
|
||||
@invariant If the ref stack contains a value, then it is an array or an
|
||||
object to which we can add elements
|
||||
*/
|
||||
template<typename BinaryValue>
|
||||
JSON_HEDLEY_RETURNS_NON_NULL
|
||||
BasicJsonType* handle_binary(BinaryValue&& v)
|
||||
{
|
||||
if (ref_stack.empty())
|
||||
{
|
||||
root = BasicJsonType::binary_array(std::forward<BinaryValue>(v));
|
||||
return &root;
|
||||
}
|
||||
|
||||
assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
|
||||
|
||||
if (ref_stack.back()->is_array())
|
||||
{
|
||||
ref_stack.back()->m_value.array->emplace_back(BasicJsonType::binary_array(std::forward<BinaryValue>(v)));
|
||||
return &(ref_stack.back()->m_value.array->back());
|
||||
}
|
||||
|
||||
assert(ref_stack.back()->is_object());
|
||||
assert(object_element);
|
||||
*object_element = BasicJsonType::binary_array(std::forward<BinaryValue>(v));
|
||||
return object_element;
|
||||
}
|
||||
|
||||
/// the parsed JSON value
|
||||
BasicJsonType& root;
|
||||
/// stack to model hierarchy of values
|
||||
@ -5101,7 +5071,7 @@ class json_sax_dom_callback_parser
|
||||
|
||||
bool binary(binary_t& val)
|
||||
{
|
||||
handle_value(val);
|
||||
handle_value(BasicJsonType::binary_array(val));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -18280,7 +18250,7 @@ class basic_json
|
||||
/// get a pointer to the value (binary)
|
||||
binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept
|
||||
{
|
||||
return is_binary() ? m_value.binary : nullptr;
|
||||
return is_binary() ? reinterpret_cast<binary_t*>(m_value.binary) : nullptr;
|
||||
}
|
||||
|
||||
/// get a pointer to the value (binary)
|
||||
|
Reference in New Issue
Block a user