fix memory leak in test case
This commit is contained in:
@@ -7830,6 +7830,8 @@ void foreign_key_test_entry_cb(const char *table_name, const char *table_line, e
|
||||
strcpy(file2_to_del, file2_localname);
|
||||
g_test_foreign_del_OK = 1;
|
||||
}
|
||||
|
||||
cJSON_Delete(json);
|
||||
}
|
||||
|
||||
TEST_F(MaatCmd, SetFile) {
|
||||
@@ -8012,6 +8014,8 @@ void plugin_ex_new_cb(const char *table_name, const char *key,
|
||||
EXPECT_TRUE(tmp_obj != NULL);
|
||||
snprintf(u->name, sizeof(u->name), "%s", tmp_obj->valuestring);
|
||||
|
||||
cJSON_Delete(json);
|
||||
|
||||
*ad = u;
|
||||
(*counter)++;
|
||||
}
|
||||
|
||||
@@ -199,12 +199,11 @@ int object_group_table_set_line(struct maat *maat_inst, const char *table_name,
|
||||
const char exc_object_uuid_strs[][UUID_STR_LEN], int exc_object_num, int expire_after)
|
||||
{
|
||||
cJSON *json_root = cJSON_CreateObject();
|
||||
cJSON *inc_object_uuid_str_array = cJSON_CreateArray();
|
||||
cJSON *exc_object_uuid_str_array = cJSON_CreateArray();
|
||||
|
||||
cJSON_AddStringToObject(json_root, "object_uuid", object_uuid_str);
|
||||
|
||||
if (inc_object_num > 0) {
|
||||
cJSON *inc_object_uuid_str_array = cJSON_CreateArray();
|
||||
for (int i = 0; i < inc_object_num; i++) {
|
||||
cJSON_AddItemToArray(inc_object_uuid_str_array, cJSON_CreateString(inc_object_uuid_strs[i]));
|
||||
}
|
||||
@@ -212,6 +211,7 @@ int object_group_table_set_line(struct maat *maat_inst, const char *table_name,
|
||||
}
|
||||
|
||||
if (exc_object_num > 0) {
|
||||
cJSON *exc_object_uuid_str_array = cJSON_CreateArray();
|
||||
for (int i = 0; i < exc_object_num; i++) {
|
||||
cJSON_AddItemToArray(exc_object_uuid_str_array, cJSON_CreateString(exc_object_uuid_strs[i]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user