From 2195f1f610719f9fdce4aa21f154d5a068de2cbb Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 28 Nov 2012 08:15:29 +0100 Subject: [PATCH] varnish plugin: Make sure the argument passed to VSM_n_Arg() is not NULL. Fixes Github issue 202. --- src/varnish.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) 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."); -- 2.11.0