Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix: lrmd: Avoid memory leak in resources_action_create()

  • Loading branch information...
commit eff656103dad5bce0964a77debcbfd1dcf53bc76 1 parent 48932af
Andrew Beekhof authored
Showing with 17 additions and 9 deletions.
  1. +12 −5 lib/services/services.c
  2. +5 −4 lrmd/lrmd.c
17 lib/services/services.c
View
@@ -70,27 +70,27 @@ resources_action_create(const char *name, const char *standard, const char *prov
if (crm_strlen_zero(name)) {
crm_err("A service or resource action must have a name.");
- return NULL;
+ goto return_error;
}
if (crm_strlen_zero(standard)) {
crm_err("A service action must have a valid standard.");
- return NULL;
+ goto return_error;
}
if (!strcasecmp(standard, "ocf") && crm_strlen_zero(provider)) {
crm_err("An OCF resource action must have a provider.");
- return NULL;
+ goto return_error;
}
if (crm_strlen_zero(agent)) {
crm_err("A service or resource action must have an agent.");
- return NULL;
+ goto return_error;
}
if (crm_strlen_zero(action)) {
crm_err("A service or resource action must specify an action.");
- return NULL;
+ goto return_error;
}
if (safe_str_eq(action, "monitor")
@@ -163,6 +163,7 @@ resources_action_create(const char *name, const char *standard, const char *prov
if (strcasecmp(op->standard, "ocf") == 0) {
op->provider = strdup(provider);
op->params = params;
+ params = NULL;
if (asprintf(&op->opaque->exec, "%s/resource.d/%s/%s", OCF_ROOT_DIR, provider, agent) == -1) {
goto return_error;
@@ -253,9 +254,15 @@ resources_action_create(const char *name, const char *standard, const char *prov
op = NULL;
}
+ if(params) {
+ g_hash_table_destroy(params);
+ }
return op;
return_error:
+ if(params) {
+ g_hash_table_destroy(params);
+ }
services_action_free(op);
return NULL;
9 lrmd/lrmd.c
View
@@ -5,12 +5,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -870,10 +870,11 @@ lrmd_rsc_execute_service_lib(lrmd_rsc_t * rsc, lrmd_cmd_t * cmd)
action->cb_data = cmd;
- /* 'cmd' may not be valid after this point
+ /* 'cmd' may not be valid after this point if
+ * services_action_async() returned TRUE
*
* Upstart and systemd both synchronously determine monitor/status
- * results and call action_complete (which may free 'cmd') if necessary
+ * results and call action_complete (which may free 'cmd') if necessary.
*/
if (services_action_async(action, action_complete)) {
return TRUE;
Please sign in to comment.
Something went wrong with that request. Please try again.