X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fexec.c;h=85f6cb8038a21b12a0db63668164b3585d885577;hb=21058a13ed34ade6d2de0f54e4216b255d033af1;hp=4c45dc158a267951cde5a8d608fe25be905f0a61;hpb=1ebf2f31bd2e080e6f42de640f0a3899a61501c0;p=collectd.git diff --git a/src/exec.c b/src/exec.c index 4c45dc15..85f6cb80 100644 --- a/src/exec.c +++ b/src/exec.c @@ -126,13 +126,12 @@ static int exec_config_exec (oconfig_item_t *ci) /* {{{ */ return (-1); } - pl = malloc (sizeof (*pl)); + pl = calloc (1, sizeof (*pl)); if (pl == NULL) { - ERROR ("exec plugin: malloc failed."); + ERROR ("exec plugin: calloc failed."); return (-1); } - memset (pl, '\0', sizeof (program_list_t)); if (strcasecmp ("NotificationExec", ci->key) == 0) pl->flags |= PL_NOTIF_ACTION; @@ -163,16 +162,15 @@ static int exec_config_exec (oconfig_item_t *ci) /* {{{ */ return (-1); } - pl->argv = malloc (ci->values_num * sizeof (*pl->argv)); + pl->argv = calloc (ci->values_num, sizeof (*pl->argv)); if (pl->argv == NULL) { - ERROR ("exec plugin: malloc failed."); + ERROR ("exec plugin: calloc failed."); sfree (pl->exec); sfree (pl->user); sfree (pl); return (-1); } - memset (pl->argv, '\0', ci->values_num * sizeof (char *)); { char *tmp = strrchr (ci->values[1].value.string, '/'); @@ -184,7 +182,7 @@ static int exec_config_exec (oconfig_item_t *ci) /* {{{ */ pl->argv[0] = strdup (buffer); if (pl->argv[0] == NULL) { - ERROR ("exec plugin: malloc failed."); + ERROR ("exec plugin: strdup failed."); sfree (pl->argv); sfree (pl->exec); sfree (pl->user);