Skip to content
/ server Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sql/my_json_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ bool Single_line_formatting_helper::on_add_member(const char *name,
size_t len)
{
DBUG_ASSERT(state== INACTIVE || state == DISABLED);
if (memchr(name, 0, len))
return false;
if (state != DISABLED)
{
// remove everything from the array
Expand Down Expand Up @@ -389,6 +391,12 @@ bool Single_line_formatting_helper::on_add_str(const char *str,
{
if (state == IN_ARRAY)
{
if (memchr(str, 0, len))
{
disable_and_flush();
return false;
}

// New length will be:
// "$string",
// quote + quote + comma + space = 4
Expand Down Expand Up @@ -485,4 +493,3 @@ void Single_line_formatting_helper::disable_and_flush()
buf_ptr= buffer;
state= INACTIVE;
}

8 changes: 6 additions & 2 deletions sql/my_json_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,12 @@ class Json_writer_object : public Json_writer_struct
}
Json_writer_object& add(const char *name, const char *value, size_t num_bytes)
{
add_member(name);
context.add_str(value, num_bytes);
DBUG_ASSERT(!closed);
if (my_writer)
{
add_member(name);
context.add_str(value, num_bytes);
}
return *this;
}
Json_writer_object& add(const char *name, const LEX_CSTRING &value)
Expand Down
Loading