diff options
author | Yousong Zhou <yszhou4tech@gmail.com> | 2019-10-21 06:10:26 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-10-29 08:59:37 +0100 |
commit | cc502635046a2015d07fab5a21edbda7b7b98f38 (patch) | |
tree | 8c894667b452b6caceb8307d65e0bce8d55d44c9 | |
parent | bd0ed2521476c3e5b6c1a0e0bd2c386ea809d74b (diff) | |
download | rpcd-cc502635046a2015d07fab5a21edbda7b7b98f38.tar.gz |
plugin: exec: properly free memory on parse error
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r-- | plugin.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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; |