From: Florian Forster Date: Wed, 28 Nov 2012 07:15:29 +0000 (+0100) Subject: varnish plugin: Make sure the argument passed to VSM_n_Arg() is not NULL. X-Git-Tag: collectd-5.1.2~15 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2195f1f610719f9fdce4aa21f154d5a068de2cbb;p=collectd.git varnish plugin: Make sure the argument passed to VSM_n_Arg() is not NULL. Fixes Github issue 202. --- diff --git a/src/varnish.c b/src/varnish.c index de60e39c..602f47af 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -1,8 +1,8 @@ /** * collectd - src/varnish.c - * Copyright (C) 2010 Jérôme Renard - * Copyright (C) 2010 Marc Fournier - * Copyright (C) 2010 Florian Forster + * Copyright (C) 2010 Jérôme Renard + * Copyright (C) 2010 Marc Fournier + * Copyright (C) 2010-2012 Florian Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -20,7 +20,7 @@ * Authors: * Jérôme Renard * Marc Fournier - * Florian octo Forster + * Florian octo Forster **/ /** @@ -412,11 +412,21 @@ static int varnish_read (user_data_t *ud) /* {{{ */ vd = VSM_New(); VSC_Setup(vd); - if (VSM_n_Arg(vd, conf->instance) == -1) + + if (conf->instance != NULL) { - ERROR ("Varnish plugin : unable to load statistics from instance"); - return (-1); + int status; + + status = VSM_n_Arg (vd, conf->instance); + if (status < 0) + { + ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed " + "with status %i.", + conf->instance, status); + return (-1); + } } + if (VSC_Open (vd, /* diag = */ 1)) { ERROR ("varnish plugin: Unable to load statistics.");