Skip to content
Permalink
Browse files
MDEV-20593 SIGSEGV in report_json_error_ex (on optimized builds).
When first argument to the JSON_MERGE_PATCH was NULL and second - the
invalid JSON line, the error code was garbage. So it should be set to 0
initially.
  • Loading branch information
Alexey Botchkov committed Oct 22, 2020
1 parent 620ea81 commit 21ea14d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
@@ -898,6 +898,11 @@ NULL
SELECT JSON_MERGE_PATCH(NULL, '[1,2,3]');
JSON_MERGE_PATCH(NULL, '[1,2,3]')
[1, 2, 3]
SELECT JSON_MERGE_PATCH(NULL, 'a');
JSON_MERGE_PATCH(NULL, 'a')
NULL
Warnings:
Warning 4038 Syntax error in JSON text in argument 2 to function 'json_merge_patch' at position 1
SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '[1,2,3]', '{"c":null,"d":"e"}');
JSON_MERGE_PATCH('{"a":"b"}', NULL, '[1,2,3]', '{"c":null,"d":"e"}')
{"d": "e"}
@@ -531,6 +531,7 @@ DROP TABLE merge_t;

SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '{"c":"d"}');
SELECT JSON_MERGE_PATCH(NULL, '[1,2,3]');
SELECT JSON_MERGE_PATCH(NULL, 'a');
SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '[1,2,3]', '{"c":null,"d":"e"}');

--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
@@ -2429,6 +2429,8 @@ String *Item_func_json_merge_patch::val_str(String *str)
uint n_arg;
bool empty_result, merge_to_null;

/* To report errors properly if some JSON is invalid. */
je1.s.error= je2.s.error= 0;
merge_to_null= args[0]->null_value;

for (n_arg=1; n_arg < arg_count; n_arg++)

0 comments on commit 21ea14d

Please sign in to comment.