summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2020-09-30 20:37:50 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2020-09-30 20:37:50 +0000
commit05b9cf3864a6d5336b701ccd80b5fa881222dbc9 (patch)
treec05af56ac8d743e50231542e4765704fdc2ade66
parentcf65897f1a4bd723264d641c6593df947df8211d (diff)
Fix two minor memory leaks.
the first is when a varbind index is of the type ipaddress. the second is on EOMV and the a varbind index is ipaddress or octetstring, where the wrong field is being freed (which in this case is always NULL and unused)
-rw-r--r--lib/libagentx/subagentx.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libagentx/subagentx.c b/lib/libagentx/subagentx.c
index ccb9684196b..ac2dccdb4d6 100644
--- a/lib/libagentx/subagentx.c
+++ b/lib/libagentx/subagentx.c
@@ -2686,7 +2686,9 @@ subagentx_get_free(struct subagentx_get *sag)
sao = sav->sav_sao;
index = &(sav->sav_index[j]);
if (sao->sao_index[j]->sai_vb.avb_type ==
- AGENTX_DATA_TYPE_OCTETSTRING)
+ AGENTX_DATA_TYPE_OCTETSTRING ||
+ sao->sao_index[j]->sai_vb.avb_type ==
+ AGENTX_DATA_TYPE_IPADDRESS)
free(index->sav_idata.avb_ostring.aos_string);
}
agentx_varbind_free(&(sag->sag_varbind[i].sav_vb));
@@ -3335,6 +3337,7 @@ subagentx_varbind_endofmibview(struct subagentx_varbind *sav)
{
struct subagentx_object *sao;
struct agentx_varbind *vb;
+ struct subagentx_varbind_index *index;
size_t i;
#ifdef AGENTX_DEBUG
@@ -3352,10 +3355,11 @@ subagentx_varbind_endofmibview(struct subagentx_varbind *sav)
sizeof(sao->sao_oid));
sav->sav_include = 1;
for (i = 0; i < sav->sav_indexlen; i++) {
- vb = &(sav->sav_index[i].sav_sai->sai_vb);
+ index = &(sav->sav_index[i]);
+ vb = &(index->sav_sai->sai_vb);
if (vb->avb_type == AGENTX_DATA_TYPE_OCTETSTRING ||
vb->avb_type == AGENTX_DATA_TYPE_IPADDRESS)
- free(vb->avb_data.avb_ostring.aos_string);
+ free(index->sav_idata.avb_ostring.aos_string);
}
bzero(&(sav->sav_index), sizeof(sav->sav_index));
subagentx_object_unlock(sav->sav_sao);