From 0c62bc40d4058f95dc6f3eff9da32befe4925751 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 18 Jun 2015 17:46:03 +0200 Subject: [PATCH] snmp plugin: Fix "Assigned value is garbage or undefined" warning. --- src/snmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/snmp.c b/src/snmp.c index 4dd1d10c..858d44c5 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -1053,16 +1053,17 @@ static int csnmp_dispatch_table (host_definition_t *host, data_definition_t *dat return (-1); } assert (ds->ds_num == data->values_len); + assert (data->values_len > 0); instance_list_ptr = instance_list; - value_table_ptr = malloc (sizeof (*value_table_ptr) * data->values_len); + value_table_ptr = calloc ((size_t) data->values_len, sizeof (*value_table_ptr)); if (value_table_ptr == NULL) return (-1); for (i = 0; i < data->values_len; i++) value_table_ptr[i] = value_table[i]; - vl.values_len = ds->ds_num; + vl.values_len = data->values_len; vl.values = malloc (sizeof (*vl.values) * vl.values_len); if (vl.values == NULL) { -- 2.30.2