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

MDEV-11442 Server crashes in String::length / parse_one_or_all /Item_func_json_contains_path::val_int

Didn't expect 'one_or_all' parameter to be NULL.
This commit is contained in:
Alexey Botchkov
2016-12-03 11:02:28 +04:00
parent b28626e842
commit e8c419570f
3 changed files with 6 additions and 1 deletions

View File

@ -88,6 +88,9 @@ 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('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2");
json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2") json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2")
1 1
select json_contains_path('{ "a": true }', NULL, '$.a' );
json_contains_path('{ "a": true }', NULL, '$.a' )
NULL
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1"); select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1");
json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1") json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1")
"asd" "asd"

View File

@ -35,6 +35,7 @@ select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1");
select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1", "$.ma"); 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", "$.ma");
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2"); select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2");
select json_contains_path('{ "a": true }', NULL, '$.a' );
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1"); select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1");
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY"); select json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY");

View File

@ -725,7 +725,8 @@ static int parse_one_or_all(Item *ooa_arg,
{ {
char buff[20]; char buff[20];
String *res, tmp(buff, sizeof(buff), &my_charset_bin); String *res, tmp(buff, sizeof(buff), &my_charset_bin);
res= ooa_arg->val_str(&tmp); if ((res= ooa_arg->val_str(&tmp)) == NULL)
return TRUE;
*mode_one=eq_ascii_string(res->charset(), "one", *mode_one=eq_ascii_string(res->charset(), "one",
res->ptr(), res->length()); res->ptr(), res->length());
if (!*mode_one) if (!*mode_one)