Skip to content

Commit 5982734

Browse files
committed
Fix json_normalize asan
String::c_ptr() assumes the string is null terminated, but not all results of val_str are, so use ptr() and length() instead.
1 parent ddcb242 commit 5982734

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sql/item_jsonfunc.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,13 @@ longlong Item_func_json_equals::val_int()
432432
goto end;
433433
}
434434

435-
if (json_normalize(&a_res, a->c_ptr(), a->length(), a->charset()))
435+
if (json_normalize(&a_res, a->ptr(), a->length(), a->charset()))
436436
{
437437
null_value= 1;
438438
goto end;
439439
}
440440

441-
if (json_normalize(&b_res, b->c_ptr(), b->length(), b->charset()))
441+
if (json_normalize(&b_res, b->ptr(), b->length(), b->charset()))
442442
{
443443
null_value= 1;
444444
goto end;
@@ -3962,7 +3962,7 @@ String *Item_func_json_normalize::val_str(String *buf)
39623962
goto end;
39633963

39643964
if (json_normalize(&normalized_json,
3965-
raw_json->c_ptr(), raw_json->length(),
3965+
raw_json->ptr(), raw_json->length(),
39663966
raw_json->charset()))
39673967
{
39683968
null_value= 1;

0 commit comments

Comments
 (0)