X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Famqp.c;h=2be55e0713efe186268337924357d47a6863a1b9;hb=b5a33aab585aabef83c79bf3261092ca901edf9c;hp=aba4f0122ca7c87ab4313da6cc3fd318872a9d88;hpb=24c2f247f6dc5c17b26d715346a380efababb08f;p=collectd.git diff --git a/src/amqp.c b/src/amqp.c index aba4f012..2be55e07 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -199,11 +199,11 @@ static char *camqp_strerror (camqp_config_t *conf, /* {{{ */ switch (r.reply_type) { case AMQP_RESPONSE_NORMAL: - sstrncpy (buffer, "Success", sizeof (buffer)); + sstrncpy (buffer, "Success", buffer_size); break; case AMQP_RESPONSE_NONE: - sstrncpy (buffer, "Missing RPC reply type", sizeof (buffer)); + sstrncpy (buffer, "Missing RPC reply type", buffer_size); break; case AMQP_RESPONSE_LIBRARY_EXCEPTION: @@ -215,7 +215,7 @@ static char *camqp_strerror (camqp_config_t *conf, /* {{{ */ return (sstrerror (r.library_error, buffer, buffer_size)); #endif else - sstrncpy (buffer, "End of stream", sizeof (buffer)); + sstrncpy (buffer, "End of stream", buffer_size); break; case AMQP_RESPONSE_SERVER_EXCEPTION: @@ -736,6 +736,7 @@ static int camqp_subscribe_init (camqp_config_t *conf) /* {{{ */ if (tmp == NULL) { ERROR ("amqp plugin: realloc failed."); + sfree (subscriber_threads); camqp_config_free (conf); return (ENOMEM); } @@ -925,15 +926,14 @@ static int camqp_config_connection (oconfig_item_t *ci, /* {{{ */ int status; int i; - conf = malloc (sizeof (*conf)); + conf = calloc (1, sizeof (*conf)); if (conf == NULL) { - ERROR ("amqp plugin: malloc failed."); + ERROR ("amqp plugin: calloc failed."); return (ENOMEM); } /* Initialize "conf" {{{ */ - memset (conf, 0, sizeof (*conf)); conf->publish = publish; conf->name = NULL; conf->format = CAMQP_FORMAT_COMMAND;