🐞 fix(utable): fix memleak in test case
This commit is contained in:
@@ -676,15 +676,16 @@ cJSON *ipfix_init_utable_from_log_json(struct utable *table, const char *test_js
|
||||
|
||||
cJSON *json_array = cJSON_CreateIntArray((const int *)array, array_sz);
|
||||
cJSON_Delete(item->child);
|
||||
item->type = cJSON_String;
|
||||
item->child = NULL;
|
||||
|
||||
item->type = cJSON_String;
|
||||
item->valuestring = cJSON_PrintUnformatted(json_array);
|
||||
cJSON_Delete(json_array);
|
||||
|
||||
free(array);
|
||||
free(long_array);
|
||||
}
|
||||
if (array_item->type == cJSON_String)
|
||||
else if (array_item->type == cJSON_String)
|
||||
{
|
||||
char **array = (char **)malloc(sizeof(char *) * array_sz);
|
||||
size_t *sz_value = (size_t *)malloc(sizeof(size_t) * array_sz);
|
||||
@@ -698,7 +699,7 @@ cJSON *ipfix_init_utable_from_log_json(struct utable *table, const char *test_js
|
||||
}
|
||||
}
|
||||
utable_add_cstring_array(table, item->string, (const char **)array, sz_value, array_sz);
|
||||
|
||||
free(sz_value);
|
||||
cJSON *json_array = cJSON_CreateStringArray((const char **)array, array_sz);
|
||||
item->valuestring = cJSON_PrintUnformatted(json_array);
|
||||
item->type = cJSON_String;
|
||||
|
||||
Reference in New Issue
Block a user