From: Ryan McCabe Date: Wed, 4 Dec 2019 15:32:15 +0000 (-0500) Subject: amqp1: Fix leaks on error paths X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f22e31f058941a4d3f72a98d4d24264c07afd080;p=collectd.git amqp1: Fix leaks on error paths Fix a few memory leaks on error paths in the amqp1 plugin. ChangeLog: amqp1 plugin: Fix leaks on error paths. Signed-off-by: Ryan McCabe --- diff --git a/src/amqp1.c b/src/amqp1.c index 67c96b75..4325f001 100644 --- a/src/amqp1.c +++ b/src/amqp1.c @@ -572,8 +572,10 @@ static int amqp1_config_instance(oconfig_item_t *ci) /* {{{ */ else if (strcasecmp("Format", child->key) == 0) { char *key = NULL; status = cf_util_get_string(child, &key); - if (status != 0) + if (status != 0) { + amqp1_config_instance_free(instance); return status; + } assert(key != NULL); if (strcasecmp(key, "Command") == 0) { instance->format = AMQP1_FORMAT_COMMAND; @@ -627,12 +629,14 @@ static int amqp1_config_instance(oconfig_item_t *ci) /* {{{ */ status = ssnprintf(tpname, sizeof(tpname), "amqp1/%s", instance->name); if ((status < 0) || (size_t)status >= sizeof(tpname)) { ERROR("amqp1 plugin: Instance name would have been truncated."); + amqp1_config_instance_free(instance); return -1; } status = ssnprintf(instance->send_to, sizeof(instance->send_to), "/%s/%s", transport->address, instance->name); if ((status < 0) || (size_t)status >= sizeof(instance->send_to)) { ERROR("amqp1 plugin: send_to address would have been truncated."); + amqp1_config_instance_free(instance); return -1; } if (instance->notify) {