diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index b00fe2e4..c2d9f99f 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -125,7 +125,9 @@ backend_terminate(clixon_handle h) /* Delete all plugins, RPC callbacks, and upgrade callbacks */ clixon_plugin_module_exit(h); /* Delete all process-control entries */ - clixon_process_delete_all(h); + clixon_process_delete_all(h); + /* Free memory associated with plugin_rpc_err() */ + clixon_plugin_rpc_err_exit(h); xpath_optimize_exit(); clixon_pagination_free(h); diff --git a/lib/clixon/clixon_plugin.h b/lib/clixon/clixon_plugin.h index 9d0a068d..820a7dec 100644 --- a/lib/clixon/clixon_plugin.h +++ b/lib/clixon/clixon_plugin.h @@ -555,6 +555,7 @@ int clixon_plugin_module_exit(clixon_handle h); int clixon_plugin_rpc_err(clixon_handle h, const char *ns, const char *type, const char *tag, const char *info, const char *severity, const char *fmt, ...); +void clixon_plugin_rpc_err_exit(clixon_handle h); int clixon_plugin_rpc_err_set(clixon_handle h); int clixon_plugin_report_err(clixon_handle h, cbuf *cbret); int clixon_plugin_report_err_xml(clixon_handle h, cxobj **xreg, char *err, ...); diff --git a/lib/src/clixon_plugin.c b/lib/src/clixon_plugin.c index 59764b31..62e88bce 100644 --- a/lib/src/clixon_plugin.c +++ b/lib/src/clixon_plugin.c @@ -1793,6 +1793,7 @@ clixon_plugin_rpc_err(clixon_handle h, int retval = -1; int err; cvec *cvv = NULL; + cvec *old_cvv = clicon_data_cvec_get(h, "rpc_err"); cvv = cvec_new(0); if (!cvv) @@ -1838,10 +1839,27 @@ clixon_plugin_rpc_err(clixon_handle h, done: if (retval && cvv) cvec_free(cvv); + if (!retval && old_cvv) + cvec_free(old_cvv); return retval; } +/*! Frees memory associated with clixon_rpc_err(). + * + * @param[in] h Clixon + */ +void +clixon_plugin_rpc_err_exit(clixon_handle h) +{ + cvec *cvv = clicon_data_cvec_get(h, "rpc_err"); + + clicon_ptr_del(h, "rpc_err"); + cvec_free(cvv); +} + /*! Returns if the rpc error has already been set. + * + * @param[in] h Clixon * * @retval 0 The rpc error is not set * @retval 1 The rpc error is set