summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2019-10-21 06:10:26 +0000
committerJo-Philipp Wich <jo@mein.io>2020-05-26 16:18:26 +0200
commit5cd4f4e57ff955e3c34ce2812e70144c6af2a485 (patch)
tree31f2f3c76ec8db5b05cd292c7b847f5877d87c9e
parentd80f70eb4af0ad447f7d34c5b9198e4fece7da57 (diff)
downloadrpcd-5cd4f4e57ff955e3c34ce2812e70144c6af2a485.tar.gz
plugin: exec: properly free memory on parse error
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> (cherry picked from commit cc502635046a2015d07fab5a21edbda7b7b98f38)
-rw-r--r--plugin.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugin.c b/plugin.c
index fa5f09f..877345d 100644
--- a/plugin.c
+++ b/plugin.c
@@ -321,11 +321,16 @@ rpc_plugin_parse_exec(const char *name, int fd)
obj_type = calloc(1, sizeof(*obj_type));
- if (!obj_type)
+ if (!obj_type) {
+ free(obj);
return NULL;
+ }
- if (asprintf((char **)&obj_type->name, "luci-rpc-plugin-%s", name) < 0)
+ if (asprintf((char **)&obj_type->name, "luci-rpc-plugin-%s", name) < 0) {
+ free(obj);
+ free(obj_type);
return NULL;
+ }
obj_type->methods = methods;
obj_type->n_methods = n_method;