1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-11143 Server crashes in json_string_set_cs.

Some JSON functions didn't expect NULL as a path.
This commit is contained in:
Alexey Botchkov
2016-12-03 11:22:42 +04:00
parent e8c419570f
commit 4ad0813a55
3 changed files with 19 additions and 0 deletions

View File

@ -91,6 +91,9 @@ json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2")
select json_contains_path('{ "a": true }', NULL, '$.a' );
json_contains_path('{ "a": true }', NULL, '$.a' )
NULL
select json_contains_path('{ "a": true }', 'all', NULL );
json_contains_path('{ "a": true }', 'all', NULL )
NULL
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1");
json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1")
"asd"

View File

@ -36,6 +36,7 @@ select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1", "$.ma");
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.ma");
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2");
select json_contains_path('{ "a": true }', NULL, '$.a' );
select json_contains_path('{ "a": true }', 'all', NULL );
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1");
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY");

View File

@ -450,6 +450,9 @@ String *Item_func_json_extract::val_str(String *str)
c_path->parsed= c_path->constant;
}
if (args[n_arg]->null_value)
goto error;
json_scan_start(&je, js->charset(),(const uchar *) js->ptr(),
(const uchar *) js->ptr() + js->length());
@ -547,6 +550,9 @@ longlong Item_func_json_extract::val_int()
c_path->parsed= c_path->constant;
}
if (args[n_arg]->null_value)
goto error;
json_scan_start(&je, js->charset(),(const uchar *) js->ptr(),
(const uchar *) js->ptr() + js->length());
@ -661,6 +667,9 @@ longlong Item_func_json_contains::val_int()
c_path->parsed= c_path->constant;
}
if (args[n_arg]->null_value)
goto error;
json_scan_start(&je, js->charset(),(const uchar *) js->ptr(),
(const uchar *) js->ptr() + js->length());
@ -768,6 +777,9 @@ longlong Item_func_json_contains_path::val_int()
c_path->parsed= c_path->constant;
}
if (args[n_arg]->null_value)
goto error;
json_scan_start(&je, js->charset(),(const uchar *) js->ptr(),
(const uchar *) js->ptr() + js->length());
@ -1946,6 +1958,9 @@ String *Item_func_json_search::val_str(String *str)
}
}
if (args[n_arg]->null_value)
goto null_return;
json_scan_start(&je, js->charset(),(const uchar *) js->ptr(),
(const uchar *) js->ptr() + js->length());