X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fsnmp.c;h=74068ec3d3dbf210a0be6e69bb2832abb17f699f;hp=3bfec47defda83161fee7c0c8810e821f260ba7d;hb=45492ba3d0119874e2f2878d68089fc8f62268a4;hpb=01d23e3f5daf016d03f82d92a76be2fe3decdca4 diff --git a/src/snmp.c b/src/snmp.c index 3bfec47d..74068ec3 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -1357,12 +1357,17 @@ static int csnmp_read_table(host_definition_t *host, data_definition_t *data) { if (oid_list_todo_num == 0) { /* The request is still empty - so we are finished */ DEBUG("snmp plugin: all variables have left their subtree"); + snmp_free_pdu(req); status = 0; break; } res = NULL; status = snmp_sess_synch_response(host->sess_handle, req, &res); + + /* snmp_sess_synch_response always frees our req PDU */ + req = NULL; + if ((status != STAT_SUCCESS) || (res == NULL)) { char *errstr = NULL; @@ -1376,8 +1381,6 @@ 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); @@ -1492,9 +1495,6 @@ 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);