plugin: exec: properly free memory on parse error

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
This commit is contained in:
Yousong Zhou 2019-10-21 06:10:26 +00:00 committed by Jo-Philipp Wich
parent bd0ed25214
commit cc50263504

View file

@ -321,11 +321,16 @@ rpc_plugin_parse_exec(const char *name, int fd)
obj_type = calloc(1, sizeof(*obj_type)); obj_type = calloc(1, sizeof(*obj_type));
if (!obj_type) if (!obj_type) {
free(obj);
return NULL; 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; return NULL;
}
obj_type->methods = methods; obj_type->methods = methods;
obj_type->n_methods = n_method; obj_type->n_methods = n_method;