Skip to content

Commit 85c1578

Browse files
committed
MDEV-32867: ASAN errors in Item_func_json_contains_path::val_int upon PS execution
This bug was caused by a patch for the task MDEV-32733. Incorrect memory root was used for allocation of memory pointed by the data memebr Item_func_json_contains_path::p_found.
1 parent ead61d9 commit 85c1578

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

mysql-test/main/ps_mem_leaks.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,13 @@ DEALLOCATE PREPARE stmt;
7979
DROP FUNCTION f1;
8080
DROP VIEW v1;
8181
DROP FUNCTION f2;
82+
#
83+
# MDEV-32867: ASAN errors in Item_func_json_contains_path::val_int upon PS execution
84+
#
85+
CREATE TABLE t1 (f BLOB) ENGINE=MyISAM;
86+
PREPARE stmt FROM "SELECT * FROM t1 WHERE JSON_EXISTS(JSON_ARRAY('[true,1234567890]'), '$**.*') != JSON_CONTAINS_PATH(JSON_INSERT('{}', '$[1]', NULL), 'all', '$[1]')";
87+
EXECUTE stmt;
88+
f
89+
DEALLOCATE PREPARE stmt;
90+
DROP TABLE t1;
8291
# End of 10.4 tests

mysql-test/main/ps_mem_leaks.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,16 @@ DROP FUNCTION f1;
9797
DROP VIEW v1;
9898
DROP FUNCTION f2;
9999

100+
--echo #
101+
--echo # MDEV-32867: ASAN errors in Item_func_json_contains_path::val_int upon PS execution
102+
--echo #
103+
CREATE TABLE t1 (f BLOB) ENGINE=MyISAM;
104+
105+
PREPARE stmt FROM "SELECT * FROM t1 WHERE JSON_EXISTS(JSON_ARRAY('[true,1234567890]'), '$**.*') != JSON_CONTAINS_PATH(JSON_INSERT('{}', '$[1]', NULL), 'all', '$[1]')";
106+
EXECUTE stmt;
107+
108+
# Clean up
109+
DEALLOCATE PREPARE stmt;
110+
DROP TABLE t1;
111+
100112
--echo # End of 10.4 tests

sql/item_jsonfunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ bool Item_func_json_contains_path::fix_fields(THD *thd, Item **ref)
14371437
if (!tmp_paths)
14381438
{
14391439
if (alloc_tmp_paths(thd, arg_count-2, &paths, &tmp_paths) ||
1440-
(p_found= (bool *) alloc_root(thd->mem_root,
1440+
(p_found= (bool *) alloc_root(thd->active_stmt_arena_to_use()->mem_root,
14411441
(arg_count-2)*sizeof(bool))) == NULL)
14421442
return true;
14431443
}

0 commit comments

Comments
 (0)