#980 Fix memleak in og_cmd_scope_get

If either root or children_root fail to be created but the other one does not,
then reserved memory for the successful one would not be freed.
master
Roberto Hueso Gómez 2020-06-30 12:39:29 +02:00 committed by OpenGnSys Support Team
parent 608709f620
commit 76c0a05f28
1 changed files with 7 additions and 2 deletions

View File

@ -2445,10 +2445,15 @@ static int og_cmd_scope_get(json_t *element, struct og_msg_params *params,
};
root = json_object();
children_root = json_array();
if (!root || !children_root)
if (!root)
return -1;
children_root = json_array();
if (!children_root) {
json_decref(root);
return -1;
}
json_object_set(root, "scope", children_root);
dbi = og_dbi_open(&dbi_config);