krb5 commit: Reuse code to free gss_mech_info structure

Greg Hudson ghudson at MIT.EDU
Sun Aug 5 13:14:31 EDT 2012


https://github.com/krb5/krb5/commit/eaf109e261e5ceebd170f35cdd7e16a3914cb037
commit eaf109e261e5ceebd170f35cdd7e16a3914cb037
Author: Simo Sorce <simo at redhat.com>
Date:   Mon Jul 30 14:12:03 2012 -0400

    Reuse code to free gss_mech_info structure

 src/lib/gssapi/mechglue/g_initialize.c |   25 ++++---------------------
 1 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c
index 202ad8e..ea7174f 100644
--- a/src/lib/gssapi/mechglue/g_initialize.c
+++ b/src/lib/gssapi/mechglue/g_initialize.c
@@ -554,7 +554,6 @@ updateMechList(void)
 #endif /* !_WIN32 */
 } /* updateMechList */
 
-#ifdef _GSS_STATIC_LINK
 static void
 releaseMechInfo(gss_mech_info *pCf)
 {
@@ -578,11 +577,11 @@ releaseMechInfo(gss_mech_info *pCf)
 	if (cf->mech_type != GSS_C_NO_OID &&
 	    cf->mech_type != &cf->mech->mech_type)
 		generic_gss_release_oid(&minor_status, &cf->mech_type);
-	if (cf->mech != NULL) {
+	if (cf->mech != NULL && cf->freeMech) {
 		memset(cf->mech, 0, sizeof(*cf->mech));
 		free(cf->mech);
 	}
-	if (cf->mech_ext != NULL) {
+	if (cf->mech_ext != NULL && cf->freeMech) {
 		memset(cf->mech_ext, 0, sizeof(*cf->mech_ext));
 		free(cf->mech_ext);
 	}
@@ -595,6 +594,7 @@ releaseMechInfo(gss_mech_info *pCf)
 	*pCf = NULL;
 }
 
+#ifdef _GSS_STATIC_LINK
 /*
  * Register a mechanism.  Called with g_mechListLock held.
  */
@@ -811,27 +811,10 @@ static void
 freeMechList(void)
 {
 	gss_mech_info cf, next_cf;
-	OM_uint32 minor;
 
 	for (cf = g_mechList; cf != NULL; cf = next_cf) {
 		next_cf = cf->next;
-		if (cf->kmodName != NULL)
-			free(cf->kmodName);
-		if (cf->uLibName != NULL)
-			free(cf->uLibName);
-		if (cf->mechNameStr != NULL)
-			free(cf->mechNameStr);
-		if (cf->optionStr != NULL)
-			free(cf->optionStr);
-		if (cf->mech_type != &cf->mech->mech_type)
-			generic_gss_release_oid(&minor, &cf->mech_type);
-		if (cf->mech != NULL && cf->freeMech)
-			free(cf->mech);
-		if (cf->mech_ext != NULL && cf->freeMech)
-			free(cf->mech_ext);
-		if (cf->dl_handle != NULL)
-			(void) krb5int_close_plugin(cf->dl_handle);
-		free(cf);
+		releaseMechInfo(&cf);
 	}
 }
 


More information about the cvs-krb5 mailing list