X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsnmp.c;h=7d340d18c2398a8a26fb845d7b0e03352b53f903;hb=51a4e62d7d0e73d8d5822efaef1e3218b5ad0373;hp=045f09b13b41bd3a3eab2562e16d76618fefe72e;hpb=7d5c193fce64d04cee72619c0b54d624d5011e35;p=collectd.git diff --git a/src/snmp.c b/src/snmp.c index 045f09b1..7d340d18 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -108,7 +108,7 @@ static int csnmp_read_host (user_data_t *ud); */ static void csnmp_oid_init (oid_t *dst, oid const *src, size_t n) { - assert (n <= STATIC_ARRAY_LEN (dst->oid)); + assert (n <= STATIC_ARRAY_SIZE (dst->oid)); memcpy (dst->oid, src, sizeof (*src) * n); dst->oid_len = n; } @@ -1316,6 +1316,8 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) snmp_free_pdu (res); res = NULL; + /* snmp_synch_response already freed our PDU */ + req = NULL; sfree (errstr); csnmp_host_close_session (host); @@ -1373,12 +1375,12 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) csnmp_table_values_t *vt; oid_t vb_name; oid_t suffix; + int ret; csnmp_oid_init (&vb_name, vb->name, vb->name_length); /* Calculate the current suffix. This is later used to check that the * suffix is increasing. This also checks if we left the subtree */ - int ret; ret = csnmp_oid_suffix (&suffix, &vb_name, data->values + i); if (ret != 0) { @@ -1437,6 +1439,10 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data) snmp_free_pdu (res); res = NULL; + if (req != NULL) + snmp_free_pdu (req); + req = NULL; + if (status == 0) csnmp_dispatch_table (host, data, instance_list_head, value_list_head);