summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-06-30 12:39:29 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-06-30 16:50:11 +0200
commit76c0a05f28531bcab3f89a4dfccae4b9b8eaf72c (patch)
treec540bc8bee0b3d396cc7955fe24385f24f3cfefa
parent608709f6206eb4061a6d59eff68babd3a8562129 (diff)
#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.
-rw-r--r--src/rest.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rest.c b/src/rest.c
index 43871e4..2a90028 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -2445,9 +2445,14 @@ static int og_cmd_scope_get(json_t *element, struct og_msg_params *params,
};
root = json_object();
+ if (!root)
+ return -1;
+
children_root = json_array();
- if (!root || !children_root)
+ if (!children_root) {
+ json_decref(root);
return -1;
+ }
json_object_set(root, "scope", children_root);