snmp_pdu_free the right object at the right time in snmptool_walk
r310892 was on the right track, but unfortunately it was resolving the problem incorrectly and accidentally leaking memory in the process. - Call snmp_pdu_free on req before calling snmp_pdu_create on it at the bottom of the outer while loop - Call snmp_pdu_free on resp after calling snmpwalk_nextpdu_create in the inner loop MFC after: 12 days X-MFC with: r310729, r310892 Reported by: valgrind
This commit is contained in:
parent
648d10d168
commit
f467e93aee
@ -422,6 +422,7 @@ snmptool_get(struct snmp_toolinfo *snmptoolctx)
|
||||
snmp_pdu_create(&req, GET_PDUTYPE(snmptoolctx));
|
||||
}
|
||||
|
||||
snmp_pdu_free(&req);
|
||||
snmp_pdu_free(&resp);
|
||||
|
||||
return (0);
|
||||
@ -507,6 +508,7 @@ snmptool_walk(struct snmp_toolinfo *snmptoolctx)
|
||||
if (op == SNMP_PDU_GETBULK)
|
||||
snmpget_fix_getbulk(&req, GET_MAXREP(snmptoolctx),
|
||||
GET_NONREP(snmptoolctx));
|
||||
snmp_pdu_free(&resp);
|
||||
}
|
||||
|
||||
/* Just in case our root was a leaf. */
|
||||
@ -517,6 +519,7 @@ snmptool_walk(struct snmp_toolinfo *snmptoolctx)
|
||||
snmp_output_err_resp(snmptoolctx, &resp);
|
||||
else
|
||||
snmp_output_resp(snmptoolctx, &(resp), NULL);
|
||||
snmp_pdu_free(&resp);
|
||||
} else
|
||||
warn("Snmp dialog");
|
||||
}
|
||||
@ -526,11 +529,13 @@ snmptool_walk(struct snmp_toolinfo *snmptoolctx)
|
||||
break;
|
||||
}
|
||||
|
||||
snmp_pdu_free(&resp);
|
||||
|
||||
snmp_pdu_free(&req);
|
||||
snmp_pdu_create(&req, op);
|
||||
}
|
||||
|
||||
snmp_pdu_free(&req);
|
||||
snmp_pdu_free(&resp);
|
||||
|
||||
if (rc == 0)
|
||||
return (0);
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user