Commit 15313216 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-9993 - connect.json_udf_bin valgrind warnings

"result" may be uninitialized when json_set_item() is called directly.
parent fa10a65d
...@@ -3568,11 +3568,11 @@ my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -3568,11 +3568,11 @@ my_bool json_set_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of json_set_item_init } // end of json_set_item_init
char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, static char *json_set_item_core(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error, int w)
{ {
char *p, *path, *str = NULL; char *p, *path, *str = NULL;
int w, rc; int rc;
my_bool b = true; my_bool b = true;
PJSON jsp; PJSON jsp;
PJSNX jsx; PJSNX jsx;
...@@ -3586,13 +3586,6 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3586,13 +3586,6 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item) } else if (initid->const_item)
g->N = 1; g->N = 1;
if (!strcmp(result, "$insert"))
w = 1;
else if (!strcmp(result, "$update"))
w = 2;
else
w = 0;
// Save stack and allocation environment and prepare error return // Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) { if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS)); PUSH_WARNING(MSG(TOO_MANY_JUMPS));
...@@ -3671,7 +3664,13 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3671,7 +3664,13 @@ char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of json_set_item } // end of json_set_item_core
char *json_set_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error)
{
return json_set_item_core(initid, args, result, res_length, is_null, error, 0);
}
void json_set_item_deinit(UDF_INIT* initid) void json_set_item_deinit(UDF_INIT* initid)
{ {
...@@ -3689,8 +3688,7 @@ my_bool json_insert_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -3689,8 +3688,7 @@ my_bool json_insert_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
char *json_insert_item(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_insert_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *p) unsigned long *res_length, char *is_null, char *p)
{ {
strcpy(result, "$insert"); return json_set_item_core(initid, args, result, res_length, is_null, p, 1);
return json_set_item(initid, args, result, res_length, is_null, p);
} // end of json_insert_item } // end of json_insert_item
void json_insert_item_deinit(UDF_INIT* initid) void json_insert_item_deinit(UDF_INIT* initid)
...@@ -3709,8 +3707,7 @@ my_bool json_update_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -3709,8 +3707,7 @@ my_bool json_update_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
char *json_update_item(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_update_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *p) unsigned long *res_length, char *is_null, char *p)
{ {
strcpy(result, "$update"); return json_set_item_core(initid, args, result, res_length, is_null, p, 2);
return json_set_item(initid, args, result, res_length, is_null, p);
} // end of json_update_item } // end of json_update_item
void json_update_item_deinit(UDF_INIT* initid) void json_update_item_deinit(UDF_INIT* initid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment