From: Ruben Kerkhof Date: Sat, 4 Jul 2015 21:04:30 +0000 (+0200) Subject: varnish: fix some leaks in error paths X-Git-Tag: collectd-5.5.1~84 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f8428bc38227584fdccd9f4eddc7c80a0ca8479b;p=collectd.git varnish: fix some leaks in error paths --- diff --git a/src/varnish.c b/src/varnish.c index 8e6d95ee..b9622610 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -608,6 +608,7 @@ static int varnish_read (user_data_t *ud) /* {{{ */ status = VSM_n_Arg (vd, conf->instance); if (status < 0) { + VSM_Delete (vd); ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed " "with status %i.", conf->instance, status); @@ -621,7 +622,8 @@ static int varnish_read (user_data_t *ud) /* {{{ */ if (VSM_Open (vd)) #endif { - ERROR ("varnish plugin: Unable to load statistics."); + VSM_Delete (vd); + ERROR ("varnish plugin: Unable to open connection."); return (-1); } @@ -631,6 +633,14 @@ static int varnish_read (user_data_t *ud) /* {{{ */ #else /* if HAVE_VARNISH_V4 */ stats = VSC_Main(vd, NULL); #endif + if (!stats) + { + VSM_Delete (vd); + ERROR ("varnish plugin: Unable to get statistics."); + + return (-1); + } + varnish_monitor (conf, stats); VSM_Close (vd);