[Fedora-directory-commits] ldapserver/ldap/servers/slapd sasl_map.c, 1.10, 1.11

Noriko Hosoi nhosoi at fedoraproject.org
Thu Nov 6 00:34:21 UTC 2008


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv23087

Modified Files:
	sasl_map.c 
Log Message:
Resolves: #459302
Summary: SASL MAP: memory leak in sasl_map_init 
Fix Description: sasl_map_done put just comments to free the map list and the
private structure, but not implemented them.  Added the code to release the map
list and the private structure.



Index: sasl_map.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/sasl_map.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- sasl_map.c	5 Nov 2008 18:21:06 -0000	1.10
+++ sasl_map.c	6 Nov 2008 00:34:19 -0000	1.11
@@ -101,7 +101,6 @@
 	return new_priv;
 }
 
-#if 0 /* unused for now */
 static void 
 sasl_map_free_private(sasl_map_private **priv)
 {
@@ -109,7 +108,6 @@
 	slapi_ch_free((void**)priv);
 	*priv = NULL;
 }
-#endif
 
 /* This function does a shallow copy on the payload data supplied, so the caller should not free it, and it needs to be allocated using slapi_ch_malloc() */
 static 
@@ -132,6 +130,10 @@
 static void 
 sasl_map_free_data(sasl_map_data **dp)
 {
+	slapi_ch_free_string(&(*dp)->name);
+	slapi_ch_free_string(&(*dp)->regular_expression);
+	slapi_ch_free_string(&(*dp)->template_base_dn);
+	slapi_ch_free_string(&(*dp)->template_search_filter);
 	slapi_ch_free((void**)dp);
 }
 
@@ -287,7 +289,8 @@
 	filtertemplate = slapi_entry_attr_get_charptr( entry, "nsSaslMapFilterTemplate" );
 	map_name = slapi_entry_attr_get_charptr( entry, "cn" );
 
-	if ( (NULL == regex) || (NULL == basedntemplate) || (NULL == filtertemplate) ) {
+	if ( (NULL == map_name) || (NULL == regex) ||
+		 (NULL == basedntemplate) || (NULL == filtertemplate) ) {
 		/* Invalid entry */
 		ret = -1;
 	} else {
@@ -296,6 +299,7 @@
 	}
 
 	if (ret) {
+		slapi_ch_free((void **) &map_name);
 		slapi_ch_free((void **) &regex);
 		slapi_ch_free((void **) &basedntemplate);
 		slapi_ch_free((void **) &filtertemplate);
@@ -405,8 +409,21 @@
 int sasl_map_done()
 {
 	int ret = 0;
+	sasl_map_private *priv = sasl_map_get_global_priv();
+	sasl_map_data *dp = NULL;
+
 	/* Free the map list */
+	PR_Lock(priv->lock);
+	dp = priv->map_data_list;
+	while (dp) {
+		sasl_map_data *dp_next = dp->next;
+		sasl_map_free_data(&dp);
+		dp = dp_next;
+	}
+	PR_Unlock(priv->lock);
+
 	/* Free the private structure */
+	sasl_map_free_private(&priv);
 	return ret;
 }
 




More information about the Fedora-directory-commits mailing list