From df4e91dca395b435603421833e898ae23d1cc091 Mon Sep 17 00:00:00 2001 From: dfr Date: Mon, 4 Jan 2016 17:42:12 +0000 Subject: [PATCH] Fix a memory leak in gss_release_oid_set --- lib/libgssapi/gss_release_oid_set.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/libgssapi/gss_release_oid_set.c b/lib/libgssapi/gss_release_oid_set.c index bedb90ba8439..a46853a4a0d8 100644 --- a/lib/libgssapi/gss_release_oid_set.c +++ b/lib/libgssapi/gss_release_oid_set.c @@ -32,15 +32,25 @@ OM_uint32 gss_release_oid_set(OM_uint32 *minor_status, - gss_OID_set *set) + gss_OID_set *setp) { + gss_OID_set set; + gss_OID o; + size_t i; *minor_status = 0; - if (set && *set) { - if ((*set)->elements) - free((*set)->elements); - free(*set); - *set = GSS_C_NO_OID_SET; + if (setp) { + set = *setp; + if (set) { + for (i = 0; i < set->count; i++) { + o = &set->elements[i]; + if (o->elements) + free(o->elements); + } + free(set->elements); + free(set); + *setp = GSS_C_NO_OID_SET; + } } return (GSS_S_COMPLETE); }