diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2017-02-09 17:38:53 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2017-02-09 17:38:53 +0400 |
commit | 0e6968c2441769e912b1cf743b158f48206f933e (patch) | |
tree | 186e565488ebfc5a48f00f6ac4fa277438ebfb35 /sql/item_jsonfunc.cc | |
parent | 66c6188a4b21d81b8d882386e0b059c4a6d05224 (diff) | |
download | mariadb-git-0e6968c2441769e912b1cf743b158f48206f933e.tar.gz |
MDEV-11857 json_search() shows "Out of memory" with empty key.
We should be ready for an empty key.
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r-- | sql/item_jsonfunc.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 73b0e6b0870..3cf7b55d6e3 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -147,8 +147,10 @@ static int json_nice(json_engine_t *je, String *nice_js, const uchar *key_start= je->s.c_str; const uchar *key_end; - while (json_read_keyname_chr(je) == 0) + do + { key_end= je->s.c_str; + } while (json_read_keyname_chr(je) == 0); if (je->s.error) goto error; @@ -892,8 +894,10 @@ static int check_contains(json_engine_t *js, json_engine_t *value) DBUG_ASSERT(value->state == JST_KEY); k_start= value->s.c_str; - while (json_read_keyname_chr(value) == 0) + do + { k_end= value->s.c_str; + } while (json_read_keyname_chr(value) == 0); if (value->s.error || json_read_value(value)) return FALSE; @@ -2527,10 +2531,10 @@ skip_search: { case JST_KEY: key_start= je.s.c_str; - while (json_read_keyname_chr(&je) == 0) + do { key_end= je.s.c_str; - } + } while (json_read_keyname_chr(&je) == 0); if (je.s.error || (n_keys > 0 && str->append(", ", 2)) || str->append("\"", 1) || |