summaryrefslogtreecommitdiffstats
path: root/contrib/bsnmp/lib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bsnmp/lib')
-rw-r--r--contrib/bsnmp/lib/snmp.c6
-rw-r--r--contrib/bsnmp/lib/snmpclient.c11
2 files changed, 12 insertions, 5 deletions
diff --git a/contrib/bsnmp/lib/snmp.c b/contrib/bsnmp/lib/snmp.c
index 68f46f9..d86f88a 100644
--- a/contrib/bsnmp/lib/snmp.c
+++ b/contrib/bsnmp/lib/snmp.c
@@ -1154,8 +1154,11 @@ snmp_pdu_dump(const struct snmp_pdu *pdu)
void
snmp_value_free(struct snmp_value *value)
{
- if (value->syntax == SNMP_SYNTAX_OCTETSTRING)
+
+ if (value->syntax == SNMP_SYNTAX_OCTETSTRING) {
free(value->v.octetstring.octets);
+ value->v.octetstring.octets = NULL;
+ }
value->syntax = SNMP_SYNTAX_NULL;
}
@@ -1216,6 +1219,7 @@ snmp_pdu_free(struct snmp_pdu *pdu)
for (i = 0; i < pdu->nbindings; i++)
snmp_value_free(&pdu->bindings[i]);
+ pdu->nbindings = 0;
}
/*
diff --git a/contrib/bsnmp/lib/snmpclient.c b/contrib/bsnmp/lib/snmpclient.c
index 90b7d4a..10c58f5 100644
--- a/contrib/bsnmp/lib/snmpclient.c
+++ b/contrib/bsnmp/lib/snmpclient.c
@@ -728,8 +728,11 @@ snmp_table_fetch_async(const struct snmp_table *descr, void *list,
work->last_change = 0;
table_init_pdu(descr, &work->pdu);
- if (snmp_pdu_send(&work->pdu, table_cb, work) == -1)
+ if (snmp_pdu_send(&work->pdu, table_cb, work) == -1) {
+ free(work);
+ work = NULL;
return (-1);
+ }
return (0);
}
@@ -1231,7 +1234,7 @@ snmp_send_packet(struct snmp_pdu * pdu)
struct asn_buf b;
ssize_t ret;
- if ((buf = malloc(snmp_client.txbuflen)) == NULL) {
+ if ((buf = calloc(1, snmp_client.txbuflen)) == NULL) {
seterr(&snmp_client, "%s", strerror(errno));
return (-1);
}
@@ -1256,7 +1259,7 @@ snmp_send_packet(struct snmp_pdu * pdu)
}
free(buf);
- return pdu->request_id;
+ return (pdu->request_id);
}
/*
@@ -1352,7 +1355,7 @@ snmp_receive_packet(struct snmp_pdu *pdu, struct timeval *tv)
socklen_t optlen;
#endif
- if ((buf = malloc(snmp_client.rxbuflen)) == NULL) {
+ if ((buf = calloc(1, snmp_client.rxbuflen)) == NULL) {
seterr(&snmp_client, "%s", strerror(errno));
return (-1);
}
OpenPOWER on IntegriCloud