From: Ken Raeburn Date: Fri, 2 Mar 2007 05:30:30 +0000 (+0000) Subject: On unload, free up g_mechSet and g_mechList X-Git-Tag: krb5-1.7-alpha1~1273 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b215dee556ea0c2f603b7346170c112cac931f3b;p=krb5.git On unload, free up g_mechSet and g_mechList git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19201 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c index 0c4513cac..d948b98d1 100644 --- a/src/lib/gssapi/mechglue/g_initialize.c +++ b/src/lib/gssapi/mechglue/g_initialize.c @@ -44,9 +44,11 @@ /* Local functions */ static gss_mech_info searchMechList(const gss_OID); static void updateMechList(void); +static void freeMechList(void); static void register_mech(gss_mechanism, const char *, void *); static OM_uint32 build_mechSet(void); +static void free_mechSet(void); static void init_hardcoded(void); /* @@ -74,6 +76,8 @@ gssint_mechglue_fini(void) { k5_mutex_destroy(&g_mechSetLock); k5_mutex_destroy(&g_mechListLock); + free_mechSet(); + freeMechList(); } @@ -219,6 +223,21 @@ gss_OID_set *mechSet; } /* gss_indicate_mechs */ +/* Call with g_mechSetLock held, or during final cleanup. */ +static void +free_mechSet(void) +{ + int i; + + if (g_mechSet.count != 0) { + for (i = 0; i < g_mechSet.count; i++) + free(g_mechSet.elements[i].elements); + free(g_mechSet.elements); + g_mechSet.elements = NULL; + g_mechSet.count = 0; + } +} + static OM_uint32 build_mechSet(void) { @@ -244,13 +263,7 @@ build_mechSet(void) (void) k5_mutex_lock(&g_mechSetLock); /* if the oid list already exists we must free it first */ - if (g_mechSet.count != 0) { - for (i = 0; i < g_mechSet.count; i++) - free(g_mechSet.elements[i].elements); - free(g_mechSet.elements); - g_mechSet.elements = NULL; - g_mechSet.count = 0; - } + free_mechSet(); /* determine how many elements to have in the list */ mList = g_mechList; @@ -453,6 +466,19 @@ updateMechList(void) } /* updateMechList */ +static void +freeMechList(void) +{ + gss_mech_info cf, next_cf; + + for (cf = g_mechList; cf != NULL; cf = next_cf) { + next_cf = cf->next; + free(cf->uLibName); + free(cf->mechNameStr); + free(cf); + } +} + /* * Register a mechanism. Called with g_mechListLock held. */