diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2021-11-05 20:01:43 +0300 |
---|---|---|
committer | Sergei Krivonos <sergeikrivonos@gmail.com> | 2021-11-09 12:06:49 +0200 |
commit | 5e988ff80f51e80f4d74477c4a22a065472317d4 (patch) | |
tree | 8c7b670f865efac4c3c244573815d0232011eaf3 /sql/my_json_writer.cc | |
parent | c9b5b9321f383ff05536466e6aaad7cab7c7ccd0 (diff) | |
download | mariadb-git-5e988ff80f51e80f4d74477c4a22a065472317d4.tar.gz |
MDEV-23766: Make Json_writer assert when one tries to author invalid JSON
- Add unit test.
Diffstat (limited to 'sql/my_json_writer.cc')
-rw-r--r-- | sql/my_json_writer.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc index 1c02ca39e22..81f7593c23f 100644 --- a/sql/my_json_writer.cc +++ b/sql/my_json_writer.cc @@ -39,7 +39,7 @@ inline void Json_writer::on_start_object() #ifndef NDEBUG if(!fmt_helper.is_making_writer_calls()) { - DBUG_ASSERT(got_name == named_item_expected()); + VALIDITY_ASSERT(got_name == named_item_expected()); named_items_expectation.push_back(true); } #endif @@ -74,7 +74,7 @@ void Json_writer::start_array() #ifndef NDEBUG if(!fmt_helper.is_making_writer_calls()) { - DBUG_ASSERT(got_name == named_item_expected()); + VALIDITY_ASSERT(got_name == named_item_expected()); named_items_expectation.push_back(false); got_name= false; } @@ -98,7 +98,7 @@ void Json_writer::end_object() { #ifndef NDEBUG named_items_expectation.pop_back(); - DBUG_ASSERT(!got_name); + VALIDITY_ASSERT(!got_name); got_name= false; #endif indent_level-=INDENT_SIZE; @@ -246,8 +246,8 @@ void Json_writer::add_unquoted_str(const char* str) void Json_writer::add_unquoted_str(const char* str, size_t len) { - DBUG_ASSERT(fmt_helper.is_making_writer_calls() || - got_name == named_item_expected()); + VALIDITY_ASSERT(fmt_helper.is_making_writer_calls() || + got_name == named_item_expected()); if (on_add_str(str, len)) return; @@ -279,8 +279,8 @@ void Json_writer::add_str(const char *str) void Json_writer::add_str(const char* str, size_t num_bytes) { - DBUG_ASSERT(fmt_helper.is_making_writer_calls() || - got_name == named_item_expected()); + VALIDITY_ASSERT(fmt_helper.is_making_writer_calls() || + got_name == named_item_expected()); if (on_add_str(str, num_bytes)) return; |