Skip to content

Commit 42ad4f2

Browse files
author
Alexey Botchkov
committed
MDEV-12364 Server crashes in __memcpy_sse2_unaligned / String::copy on
JSON_SEARCH with variables. Wrong index for the tmp_paths array in Item_func_json_search::val_str.
1 parent 7afcee4 commit 42ad4f2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

mysql-test/r/func_json.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,3 +629,7 @@ j p json_remove(j, p)
629629
{"a":1,"b":2,"c":3} $.b {"a": 1, "c": 3}
630630
{"a":1,"b":2,"c":3} $.c {"a": 1, "b": 2}
631631
drop table t1;
632+
SET @str = 'bar', @path = '$';
633+
SELECT JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path);
634+
JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path)
635+
"$.foo"

mysql-test/t/func_json.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,10 @@ insert into t1 values
274274
('{"a":1,"b":2,"c":3}','$.c');
275275
select j, p, json_remove(j, p) from t1;
276276
drop table t1;
277+
278+
#
279+
# MDEV-12364 Server crashes in __memcpy_sse2_unaligned / String::copy on JSON_SEARCH with variables.
280+
#
281+
SET @str = 'bar', @path = '$';
282+
SELECT JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path);
283+

sql/item_jsonfunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2898,7 +2898,7 @@ String *Item_func_json_search::val_str(String *str)
28982898
json_path_with_flags *c_path= paths + n_arg - 4;
28992899
if (!c_path->parsed)
29002900
{
2901-
String *s_p= args[n_arg]->val_str(tmp_paths + (n_arg-1));
2901+
String *s_p= args[n_arg]->val_str(tmp_paths + (n_arg-4));
29022902
if (s_p &&
29032903
json_path_setup(&c_path->p,s_p->charset(),(const uchar *) s_p->ptr(),
29042904
(const uchar *) s_p->ptr() + s_p->length()))

0 commit comments

Comments
 (0)