andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 12552b47385b98ad294fdb1f229861998c83ec2f Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Wed, 5 Jun 2013 16:19:57 -0400
dc8c34
Subject: [PATCH 92/99] Coverity Fixes (Part 4)
dc8c34
dc8c34
11753 - Resource leak (aclparse.c)
dc8c34
11754 - Resource leak (dna.c)
dc8c34
11755 - Resource leak (dna.c)
dc8c34
11756 - Resource leak (linked_attrs.c)
dc8c34
11757 - Resource leak (pam_ptconfig.c)
dc8c34
11758 - Resource leak (repl5_replica_config.c)
dc8c34
11759 - Resource leak (windows_inc_protocol.c)
dc8c34
11760 - Resource leak (syntaxes/value.c)
dc8c34
11761 - Resource leak (dblayer.c)
dc8c34
11764 - Resource leak (dblayer.c)
dc8c34
11766 - Resource leak (dblayer.c)
dc8c34
11769 - Resource leak (entry.c)
dc8c34
11770 - Resource leak (entry.c)
dc8c34
11773 - Resource leak (schema.c)
dc8c34
11774 - Resource leak (snmp_collator.c)
dc8c34
11775 - Resource leak (ldclt/data.c)
dc8c34
11776 - Resource leak (tools/mmldif.c)
dc8c34
11777 - Resource leak (snmp/main.c)
dc8c34
11778 - Resource leak (lib/libutil/dbconf.c)
dc8c34
11779 - Resource leak (lib/libaccess/register.cpp)
dc8c34
11781 - Resource leak (lib/libadmin/error.c)
dc8c34
11872 - Resource leak (agtmmap.c)
dc8c34
dc8c34
https://bugzilla.redhat.com/show_bug.cgi?id=970221
dc8c34
dc8c34
Reviewed by: nhosoi(Thanks!)
dc8c34
(cherry picked from commit 26127d5f7a96c33dfc46f3c8fc21de07455ea667)
dc8c34
(cherry picked from commit 3ab5aba6252798b895953a6f2af50916d3525ceb)
dc8c34
---
dc8c34
 ldap/servers/plugins/acl/acl.h                     |  1 +
dc8c34
 ldap/servers/plugins/acl/acllist.c                 |  7 +++---
dc8c34
 ldap/servers/plugins/acl/aclparse.c                | 29 +++++++++++-----------
dc8c34
 ldap/servers/plugins/dna/dna.c                     |  7 ++++++
dc8c34
 ldap/servers/plugins/linkedattrs/linked_attrs.c    |  7 ++++++
dc8c34
 ldap/servers/plugins/pam_passthru/pam_ptconfig.c   |  6 +++++
dc8c34
 .../plugins/replication/repl5_replica_config.c     |  3 +--
dc8c34
 .../plugins/replication/windows_inc_protocol.c     |  1 +
dc8c34
 ldap/servers/plugins/syntaxes/value.c              | 14 +++++++++++
dc8c34
 ldap/servers/slapd/agtmmap.c                       |  1 +
dc8c34
 ldap/servers/slapd/back-ldbm/dblayer.c             | 14 +++++++----
dc8c34
 ldap/servers/slapd/entry.c                         |  7 +++++-
dc8c34
 ldap/servers/slapd/schema.c                        |  6 +++--
dc8c34
 ldap/servers/slapd/snmp_collator.c                 |  4 ++-
dc8c34
 ldap/servers/slapd/tools/ldclt/data.c              |  2 ++
dc8c34
 ldap/servers/slapd/tools/mmldif.c                  |  6 +++++
dc8c34
 ldap/servers/snmp/main.c                           |  3 +++
dc8c34
 lib/ldaputil/dbconf.c                              |  7 ++++--
dc8c34
 lib/libaccess/register.cpp                         |  1 +
dc8c34
 lib/libadmin/error.c                               |  7 ++++--
dc8c34
 20 files changed, 99 insertions(+), 34 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
dc8c34
index e2b04c3..c61ee70 100644
dc8c34
--- a/ldap/servers/plugins/acl/acl.h
dc8c34
+++ b/ldap/servers/plugins/acl/acl.h
dc8c34
@@ -866,6 +866,7 @@ int			acllist_moddn_aci_needsLock ( Slapi_DN *oldsdn, char *newdn );
dc8c34
 void		acllist_print_tree ( Avlnode *root, int *depth, char *start, char *side);
dc8c34
 AciContainer *acllist_get_aciContainer_new ( );
dc8c34
 void 		acllist_done_aciContainer (  AciContainer *);
dc8c34
+void		free_targetattrfilters( Targetattrfilter ***attrFilterArray);
dc8c34
 
dc8c34
 aclUserGroup* aclg_find_userGroup (const char *n_dn);
dc8c34
 void 		aclg_regen_ugroup_signature( aclUserGroup *ugroup);
dc8c34
diff --git a/ldap/servers/plugins/acl/acllist.c b/ldap/servers/plugins/acl/acllist.c
dc8c34
index e8198af..623a739 100644
dc8c34
--- a/ldap/servers/plugins/acl/acllist.c
dc8c34
+++ b/ldap/servers/plugins/acl/acllist.c
dc8c34
@@ -94,7 +94,6 @@ static int		__acllist_add_aci ( aci_t *aci );
dc8c34
 static int		__acllist_aciContainer_node_cmp ( caddr_t d1, caddr_t d2 );
dc8c34
 static int		__acllist_aciContainer_node_dup ( caddr_t d1, caddr_t d2 );
dc8c34
 static void 	__acllist_free_aciContainer (  AciContainer **container);
dc8c34
-static void free_targetattrfilters( Targetattrfilter ***input_attrFilterArray);
dc8c34
 
dc8c34
 void my_print( Avlnode	*root );
dc8c34
 
dc8c34
@@ -565,8 +564,9 @@ acllist_free_aci(aci_t *item)
dc8c34
 	slapi_ch_free ( (void **) &item );
dc8c34
 }
dc8c34
 
dc8c34
-static void free_targetattrfilters( Targetattrfilter ***attrFilterArray) {    
dc8c34
-    
dc8c34
+void
dc8c34
+free_targetattrfilters( Targetattrfilter ***attrFilterArray)
dc8c34
+{
dc8c34
     if (*attrFilterArray) {
dc8c34
 		int			i = 0;
dc8c34
 		Targetattrfilter		*attrfilter;
dc8c34
@@ -592,7 +592,6 @@ static void free_targetattrfilters( Targetattrfilter ***attrFilterArray) {
dc8c34
 		/* Now free the array */
dc8c34
 		slapi_ch_free ( (void **) attrFilterArray );
dc8c34
 	}
dc8c34
-    
dc8c34
 }
dc8c34
 
dc8c34
 /* SEARCH */
dc8c34
diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c
dc8c34
index 39d9f6c..8b11471 100644
dc8c34
--- a/ldap/servers/plugins/acl/aclparse.c
dc8c34
+++ b/ldap/servers/plugins/acl/aclparse.c
dc8c34
@@ -1935,14 +1935,13 @@ static int __acl__init_targetattrfilters( aci_t *aci, char *input_str) {
dc8c34
  * We need to put each component into a targetattrfilter component of
dc8c34
  * the array.
dc8c34
  *
dc8c34
-*/
dc8c34
-
dc8c34
+ */
dc8c34
 static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
dc8c34
 						  char * input_str) {
dc8c34
 
dc8c34
 	char *str, *end_attr;
dc8c34
 	Targetattrfilter *attrfilter = NULL;
dc8c34
-	int		numattr=0;
dc8c34
+	int		numattr=0, rc = 0;
dc8c34
 	Targetattrfilter **attrFilterArray = NULL;
dc8c34
 
dc8c34
 	str = input_str;
dc8c34
@@ -1974,22 +1973,20 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
dc8c34
 		memset (attrfilter, 0, sizeof(Targetattrfilter));
dc8c34
 
dc8c34
 		if (strstr( str,":") != NULL) {
dc8c34
-			
dc8c34
 			if ( __acl_init_targetattrfilter( attrfilter, str ) != 0 ) {
dc8c34
 				slapi_ch_free((void**)&attrfilter);
dc8c34
-				return(ACL_SYNTAX_ERR);
dc8c34
+				rc = ACL_SYNTAX_ERR;
dc8c34
+				break;
dc8c34
 			}        
dc8c34
 		} else {
dc8c34
 			slapi_ch_free((void**)&attrfilter);
dc8c34
-			return(ACL_SYNTAX_ERR);
dc8c34
+			rc = ACL_SYNTAX_ERR;
dc8c34
+			break;
dc8c34
 		}
dc8c34
 
dc8c34
-
dc8c34
 		/*
dc8c34
-		 * Add the attrfilte to the targetAttrFilter list
dc8c34
-		*/
dc8c34
-
dc8c34
-     	
dc8c34
+		 * Add the attrfilter to the targetAttrFilter list
dc8c34
+		 */
dc8c34
 		attrFilterArray = (Targetattrfilter **) slapi_ch_realloc (
dc8c34
 						    (void *) attrFilterArray,
dc8c34
 						    ((numattr+1)*sizeof(Targetattrfilter *)) ); 
dc8c34
@@ -1998,7 +1995,6 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
dc8c34
 	
dc8c34
 		/* Move on to the next attribute in the list */
dc8c34
 		str = end_attr;
dc8c34
-
dc8c34
 	}/* while */
dc8c34
 
dc8c34
 	/* NULL terminate the list */
dc8c34
@@ -2007,10 +2003,13 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
dc8c34
 						    (void *) attrFilterArray,
dc8c34
 						    ((numattr+1)*sizeof(Targetattrfilter *)) ); 
dc8c34
 	attrFilterArray[numattr] = NULL;
dc8c34
+	if(rc){
dc8c34
+		free_targetattrfilters(&attrFilterArray);
dc8c34
+	} else {
dc8c34
+		*input_attrFilterArray = attrFilterArray;
dc8c34
+	}
dc8c34
 
dc8c34
-	*input_attrFilterArray = attrFilterArray;
dc8c34
-	return 0;
dc8c34
-
dc8c34
+	return rc;
dc8c34
 }
dc8c34
 
dc8c34
 /*
dc8c34
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
dc8c34
index d3dfa52..958a4a7 100644
dc8c34
--- a/ldap/servers/plugins/dna/dna.c
dc8c34
+++ b/ldap/servers/plugins/dna/dna.c
dc8c34
@@ -1515,11 +1515,13 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
dc8c34
                      * to lowest. */
dc8c34
                     struct dnaServer *sitem;
dc8c34
                     PRCList* item = PR_LIST_HEAD(*servers);
dc8c34
+                    int inserted = 0;
dc8c34
 
dc8c34
                     while (item != *servers) {
dc8c34
                         sitem = (struct dnaServer *)item;
dc8c34
                         if (server->remaining > sitem->remaining) {
dc8c34
                             PR_INSERT_BEFORE(&(server->list), item);
dc8c34
+                            inserted = 1;
dc8c34
                             break;
dc8c34
                         }
dc8c34
 
dc8c34
@@ -1528,9 +1530,13 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
dc8c34
                         if (*servers == item) {
dc8c34
                             /* add to tail */
dc8c34
                             PR_INSERT_BEFORE(&(server->list), item);
dc8c34
+                            inserted = 1;
dc8c34
                             break;
dc8c34
                         }
dc8c34
                     }
dc8c34
+                    if(!inserted){
dc8c34
+                    	dna_free_shared_server(&server);
dc8c34
+                    }
dc8c34
                 }
dc8c34
             }
dc8c34
         }
dc8c34
@@ -3340,6 +3346,7 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
dc8c34
 bail:
dc8c34
     if (resulting_e)
dc8c34
         slapi_entry_free(resulting_e);
dc8c34
+    slapi_mods_free(&smods);
dc8c34
 
dc8c34
     if (ret) {
dc8c34
         slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
dc8c34
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
dc8c34
index 4bea10f..7d8370d 100644
dc8c34
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
dc8c34
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
dc8c34
@@ -755,6 +755,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
dc8c34
     struct configEntry *config_entry = NULL;
dc8c34
     struct configIndex *index_entry = NULL;
dc8c34
     PRCList *list = PR_LIST_HEAD(g_managed_config_index);
dc8c34
+    int inserted = 0;
dc8c34
 
dc8c34
     index_entry = (struct configIndex *)slapi_ch_calloc(1, sizeof(struct configIndex));
dc8c34
     index_entry->config = entry;
dc8c34
@@ -769,6 +770,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
dc8c34
                 slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
dc8c34
                                 "store [%s] before [%s] \n", entry->dn,
dc8c34
                                 config_entry->dn);
dc8c34
+                inserted = 1;
dc8c34
                 break;
dc8c34
             }
dc8c34
     
dc8c34
@@ -779,6 +781,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
dc8c34
                 PR_INSERT_BEFORE(&(index_entry->list), list);
dc8c34
                 slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
dc8c34
                                 "store [%s] at tail\n", entry->dn);
dc8c34
+                inserted = 1;
dc8c34
                 break;
dc8c34
             }
dc8c34
         }
dc8c34
@@ -787,6 +790,10 @@ linked_attrs_insert_config_index(struct configEntry *entry)
dc8c34
         slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
dc8c34
                         "store [%s] at head \n", entry->dn);
dc8c34
         PR_INSERT_LINK(&(index_entry->list), g_managed_config_index);
dc8c34
+        inserted = 1;
dc8c34
+    }
dc8c34
+    if(!inserted){
dc8c34
+    	slapi_ch_free((void **)&index_entry);
dc8c34
     }
dc8c34
 }
dc8c34
 
dc8c34
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
dc8c34
index fce8000..9391891 100644
dc8c34
--- a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
dc8c34
+++ b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
dc8c34
@@ -603,6 +603,7 @@ pam_passthru_apply_config (Slapi_Entry* e)
dc8c34
     PRCList *list;
dc8c34
     Slapi_Attr *a = NULL;
dc8c34
     char *filter_str = NULL;
dc8c34
+    int inserted = 0;
dc8c34
 
dc8c34
     pam_ident_attr = slapi_entry_attr_get_charptr(e, PAMPT_PAM_IDENT_ATTR);
dc8c34
     map_method = slapi_entry_attr_get_charptr(e, PAMPT_MAP_METHOD_ATTR);
dc8c34
@@ -689,6 +690,7 @@ pam_passthru_apply_config (Slapi_Entry* e)
dc8c34
                 PR_INSERT_BEFORE(&(entry->list), list);
dc8c34
                 slapi_log_error(SLAPI_LOG_CONFIG, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
dc8c34
                                 "store [%s] at tail\n", entry->dn);
dc8c34
+                inserted = 1;
dc8c34
                 break;
dc8c34
             }
dc8c34
         }
dc8c34
@@ -697,9 +699,13 @@ pam_passthru_apply_config (Slapi_Entry* e)
dc8c34
         PR_INSERT_LINK(&(entry->list), pam_passthru_global_config);
dc8c34
         slapi_log_error(SLAPI_LOG_CONFIG, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
dc8c34
                         "store [%s] at head \n", entry->dn);
dc8c34
+        inserted = 1;
dc8c34
     }
dc8c34
 
dc8c34
   bail:
dc8c34
+    if(!inserted){
dc8c34
+    	pam_passthru_free_config_entry(&entry);
dc8c34
+    }
dc8c34
     slapi_ch_free_string(&new_service);
dc8c34
     slapi_ch_free_string(&map_method);
dc8c34
     slapi_ch_free_string(&pam_ident_attr);
dc8c34
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
dc8c34
index 7b684e9..5ca7706 100644
dc8c34
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
dc8c34
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
dc8c34
@@ -1745,7 +1745,7 @@ check_replicas_are_done_cleaning(cleanruv_data *data )
dc8c34
 {
dc8c34
     Object *agmt_obj;
dc8c34
     Repl_Agmt *agmt;
dc8c34
-    char *csnstr = NULL;
dc8c34
+    char csnstr[CSN_STRSIZE];
dc8c34
     char *filter = NULL;
dc8c34
     int not_all_cleaned = 1;
dc8c34
     int interval = 10;
dc8c34
@@ -1788,7 +1788,6 @@ check_replicas_are_done_cleaning(cleanruv_data *data )
dc8c34
             interval = 14400;
dc8c34
         }
dc8c34
     }
dc8c34
-    slapi_ch_free_string(&csnstr);
dc8c34
     slapi_ch_free_string(&filter);
dc8c34
 }
dc8c34
 
dc8c34
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
dc8c34
index cb3b3d2..15d69a3 100644
dc8c34
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
dc8c34
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
dc8c34
@@ -1026,6 +1026,7 @@ windows_inc_run(Private_Repl_Protocol *prp)
dc8c34
   windows_conn_cancel_linger(prp->conn);
dc8c34
   /* ... and disconnect, if currently connected */
dc8c34
   windows_conn_disconnect(prp->conn);
dc8c34
+  ruv_destroy ( &ruv );
dc8c34
   LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_inc_run\n" );
dc8c34
 }
dc8c34
 
dc8c34
diff --git a/ldap/servers/plugins/syntaxes/value.c b/ldap/servers/plugins/syntaxes/value.c
dc8c34
index efef9a8..0335a89 100644
dc8c34
--- a/ldap/servers/plugins/syntaxes/value.c
dc8c34
+++ b/ldap/servers/plugins/syntaxes/value.c
dc8c34
@@ -282,10 +282,13 @@ value_cmp(
dc8c34
 		value_normalize_ext( v1->bv_val, syntax, 
dc8c34
 							 1 /* trim leading blanks */, &alt );
dc8c34
 		if (alt) {
dc8c34
+			int inserted = 0;
dc8c34
+
dc8c34
 			if (free_v1) {
dc8c34
 				slapi_ch_free_string(&v1->bv_val);
dc8c34
 				v1->bv_val = alt;
dc8c34
 				v1->bv_len = strlen(alt);
dc8c34
+				inserted = 1;
dc8c34
 			} else {
dc8c34
 				if (strlen(alt) < buffer_space) {
dc8c34
 					v1->bv_len = strlen(alt);
dc8c34
@@ -297,8 +300,12 @@ value_cmp(
dc8c34
 					v1 = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
dc8c34
 					v1->bv_val = alt;
dc8c34
 					v1->bv_len = strlen(alt);
dc8c34
+					inserted = 1;
dc8c34
 				}
dc8c34
 			}
dc8c34
+			if(!inserted){
dc8c34
+				slapi_ch_free_string(&alt;;
dc8c34
+			}
dc8c34
 		}
dc8c34
 		if (!free_v1) {
dc8c34
 			buffer_space -= v1->bv_len + 1;
dc8c34
@@ -320,10 +327,13 @@ value_cmp(
dc8c34
 		value_normalize_ext( v2->bv_val, syntax, 
dc8c34
 							 1 /* trim leading blanks */, &alt );
dc8c34
 		if (alt) {
dc8c34
+			int inserted = 0;
dc8c34
+
dc8c34
 			if (free_v2) {
dc8c34
 				slapi_ch_free_string(&v2->bv_val);
dc8c34
 				v2->bv_val = alt;
dc8c34
 				v2->bv_len = strlen(alt);
dc8c34
+				inserted = 1;
dc8c34
 			} else {
dc8c34
 				if (strlen(alt) < buffer_space) {
dc8c34
 					v2->bv_len = strlen(alt);
dc8c34
@@ -335,8 +345,12 @@ value_cmp(
dc8c34
 					v2 = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
dc8c34
 					v2->bv_val = alt;
dc8c34
 					v2->bv_len = strlen(alt);
dc8c34
+					inserted = 1;
dc8c34
 				}
dc8c34
 			}
dc8c34
+			if(!inserted){
dc8c34
+				slapi_ch_free_string(&alt;;
dc8c34
+			}
dc8c34
 		}
dc8c34
 		if (!free_v2) {
dc8c34
 			buffer_space -= v2->bv_len + 1;
dc8c34
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
dc8c34
index f18138a..3922547 100644
dc8c34
--- a/ldap/servers/slapd/agtmmap.c
dc8c34
+++ b/ldap/servers/slapd/agtmmap.c
dc8c34
@@ -196,6 +196,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
dc8c34
                }
dc8c34
 		
dc8c34
                if(fstat (fd, &fileinfo) != 0){
dc8c34
+                   close(fd);
dc8c34
                    rc = errno;
dc8c34
                    goto bail;
dc8c34
 		       }
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
dc8c34
index 960d99e..cb8ef68 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
dc8c34
@@ -1897,9 +1897,9 @@ dblayer_get_id2entry_size(ldbm_instance *inst)
dc8c34
 {
dc8c34
     struct ldbminfo *li = NULL;
dc8c34
     char *id2entry_file = NULL;
dc8c34
-    PRFileInfo info;
dc8c34
+    PRFileInfo64 info;
dc8c34
     int rc;
dc8c34
-    char inst_dir[MAXPATHLEN], *inst_dirp;
dc8c34
+    char inst_dir[MAXPATHLEN], *inst_dirp = NULL;
dc8c34
 
dc8c34
     if (NULL == inst) {
dc8c34
         return 0;
dc8c34
@@ -1908,7 +1908,10 @@ dblayer_get_id2entry_size(ldbm_instance *inst)
dc8c34
     inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
dc8c34
     id2entry_file = slapi_ch_smprintf("%s/%s", inst_dirp,
dc8c34
                                       ID2ENTRY LDBM_FILENAME_SUFFIX);
dc8c34
-    rc = PR_GetFileInfo(id2entry_file, &info;;
dc8c34
+    if(inst_dirp != inst_dir){
dc8c34
+        slapi_ch_free_string(&inst_dirp);
dc8c34
+    }
dc8c34
+    rc = PR_GetFileInfo64(id2entry_file, &info;;
dc8c34
     slapi_ch_free_string(&id2entry_file);
dc8c34
     if (inst_dirp != inst_dir)
dc8c34
         slapi_ch_free_string(&inst_dirp);
dc8c34
@@ -3069,6 +3072,9 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
dc8c34
         }
dc8c34
         abs_file_name = slapi_ch_smprintf("%s%c%s",
dc8c34
                 inst_dirp, get_sep(inst_dirp), file_name);
dc8c34
+        if (inst_dirp != inst_dir){
dc8c34
+            slapi_ch_free_string(&inst_dirp);
dc8c34
+        }
dc8c34
         DB_OPEN(pENV->dblayer_openflags,
dc8c34
                 dbp, NULL/* txnid */, abs_file_name, subname, DB_BTREE,
dc8c34
                 open_flags, priv->dblayer_file_mode, return_value);
dc8c34
@@ -3084,8 +3090,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
dc8c34
             goto out;
dc8c34
 
dc8c34
         slapi_ch_free_string(&abs_file_name);
dc8c34
-        if (inst_dirp != inst_dir)
dc8c34
-            slapi_ch_free_string(&inst_dirp);
dc8c34
     }
dc8c34
     DB_OPEN(pENV->dblayer_openflags,
dc8c34
             dbp, NULL, /* txnid */ rel_path, subname, DB_BTREE,
dc8c34
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
dc8c34
index f38c39e..a43dc21 100644
dc8c34
--- a/ldap/servers/slapd/entry.c
dc8c34
+++ b/ldap/servers/slapd/entry.c
dc8c34
@@ -552,6 +552,7 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo )
dc8c34
 	}
dc8c34
 
dc8c34
 done:
dc8c34
+	csnset_free(&valuecsnset);
dc8c34
 	csn_free(&attributedeletioncsn);
dc8c34
 	csn_free(&maxcsn);
dc8c34
 	LDAPDebug( LDAP_DEBUG_TRACE, "<= str2entry_fast 0x%x\n",
dc8c34
@@ -744,6 +745,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
dc8c34
 			( 0 != ( flags & SLAPI_STR2ENTRY_REMOVEDUPVALS ));
dc8c34
 	Slapi_Value *value = 0;
dc8c34
 	CSN *attributedeletioncsn= NULL;
dc8c34
+	CSNSet *valuecsnset= NULL;
dc8c34
 	CSN *maxcsn= NULL;
dc8c34
 	char *normdn = NULL;
dc8c34
 	int strict = 0;
dc8c34
@@ -764,7 +766,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
dc8c34
 	}
dc8c34
     while ( (s = ldif_getline( &next )) != NULL )
dc8c34
     {
dc8c34
-		CSNSet *valuecsnset= NULL;
dc8c34
 		int value_state= VALUE_NOTFOUND;
dc8c34
 		int attr_state= VALUE_NOTFOUND;
dc8c34
 		int freeval = 0;
dc8c34
@@ -819,6 +820,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
dc8c34
 						    "str2entry_dupcheck: Invalid DN: %s\n", rawdn);
dc8c34
 						slapi_entry_free( e );
dc8c34
 						if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
dc8c34
+						csnset_free(&valuecsnset);
dc8c34
 						csn_free(&attributedeletioncsn);
dc8c34
 						csn_free(&maxcsn);
dc8c34
 						return NULL;
dc8c34
@@ -841,6 +843,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
dc8c34
 							     "str2entry_dupcheck: Invalid DN: %s\n", rawdn);
dc8c34
 							slapi_entry_free( e );
dc8c34
 							if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
dc8c34
+							csnset_free(&valuecsnset);
dc8c34
 							csn_free(&attributedeletioncsn);
dc8c34
 							csn_free(&maxcsn);
dc8c34
 							return NULL;
dc8c34
@@ -954,6 +957,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
dc8c34
 						if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
dc8c34
 						csn_free(&attributedeletioncsn);
dc8c34
 						csn_free(&maxcsn);
dc8c34
+						csnset_free(&valuecsnset);
dc8c34
 						return NULL;
dc8c34
 					}
dc8c34
 					for ( i = 0; i < nattrs; i++ )
dc8c34
@@ -1285,6 +1289,7 @@ free_and_return:
dc8c34
 	}
dc8c34
 	slapi_ch_free((void **) &dyn_attrs );
dc8c34
 	if (value) slapi_value_free(&value);
dc8c34
+	csnset_free(&valuecsnset);
dc8c34
 	csn_free(&attributedeletioncsn);
dc8c34
 	csn_free(&maxcsn);
dc8c34
 
dc8c34
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
dc8c34
index 1768c7e..258f6eb 100644
dc8c34
--- a/ldap/servers/slapd/schema.c
dc8c34
+++ b/ldap/servers/slapd/schema.c
dc8c34
@@ -3083,11 +3083,11 @@ read_oc_ldif ( const char *input, struct objclass **oc, char *errorbuf,
dc8c34
   pnew_oc->oc_kind = kind;
dc8c34
 
dc8c34
   *oc = pnew_oc;
dc8c34
+
dc8c34
   return read_oc_ldif_return( LDAP_SUCCESS, pOcOid, psbOcName, pOcSup,
dc8c34
 			oc_origins, num_origins, pOcDesc );
dc8c34
 }
dc8c34
 
dc8c34
-
dc8c34
 static void
dc8c34
 oc_free( struct objclass **ocp )
dc8c34
 {
dc8c34
@@ -3969,7 +3969,9 @@ load_schema_dse(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *ignored,
dc8c34
             if ( LDAP_SUCCESS != (*returncode = read_oc_ldif(s, &oc, returntext,
dc8c34
                         SLAPI_DSE_RETURNTEXT_SIZE, flags,
dc8c34
                         primary_file /* force user defined? */,
dc8c34
-                        schema_ds4x_compat))) {
dc8c34
+                        schema_ds4x_compat)))
dc8c34
+            {
dc8c34
+            	oc_free( &oc );
dc8c34
                 break;
dc8c34
             }
dc8c34
             if (flags & DSE_SCHEMA_NO_LOAD)
dc8c34
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
dc8c34
index aeac7ae..b3d072a 100644
dc8c34
--- a/ldap/servers/slapd/snmp_collator.c
dc8c34
+++ b/ldap/servers/slapd/snmp_collator.c
dc8c34
@@ -738,8 +738,10 @@ snmp_update_cache_stats()
dc8c34
 
dc8c34
     /* set the cache hits/cache entries info */
dc8c34
     be = slapi_get_first_backend(&cookie);
dc8c34
-    if (!be)
dc8c34
+    if (!be){
dc8c34
+    	slapi_ch_free ((void **) &cookie);
dc8c34
         return;
dc8c34
+    }
dc8c34
 
dc8c34
     be_next = slapi_get_next_backend(cookie);
dc8c34
 
dc8c34
diff --git a/ldap/servers/slapd/tools/ldclt/data.c b/ldap/servers/slapd/tools/ldclt/data.c
dc8c34
index e0eac55..f6dd4ef 100644
dc8c34
--- a/ldap/servers/slapd/tools/ldclt/data.c
dc8c34
+++ b/ldap/servers/slapd/tools/ldclt/data.c
dc8c34
@@ -335,6 +335,8 @@ exit:
dc8c34
 #ifdef _WIN32
dc8c34
   if (findPath) free (findPath);
dc8c34
 #endif
dc8c34
+  close(fd);
dc8c34
+
dc8c34
   return rc;
dc8c34
 }
dc8c34
 
dc8c34
diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c
dc8c34
index 6d62338..fb97129 100644
dc8c34
--- a/ldap/servers/slapd/tools/mmldif.c
dc8c34
+++ b/ldap/servers/slapd/tools/mmldif.c
dc8c34
@@ -735,6 +735,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
dc8c34
     attrib1_t *	newlist = NULL;
dc8c34
     attrib1_t *	a;
dc8c34
     int		ignore_rec = FALSE;
dc8c34
+    int free_it = 0;
dc8c34
 
dc8c34
     *attrib = NULL;
dc8c34
     if (edf1->end) {
dc8c34
@@ -759,6 +760,9 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
dc8c34
                 /* that's for the case where the file */
dc8c34
                 /* has a trailing blank line */
dc8c34
                 freefreelist(freelist);
dc8c34
+                if(free_it){
dc8c34
+                	freefreelist(att);
dc8c34
+                }
dc8c34
                 return IDDS_MM_EOF;
dc8c34
             }
dc8c34
             break; /* return */
dc8c34
@@ -790,9 +794,11 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
dc8c34
             continue;
dc8c34
         if (!freelist) {
dc8c34
             att = (attrib1_t *)malloc(sizeof(attrib1_t));
dc8c34
+            free_it = 1;
dc8c34
         } else {
dc8c34
             att = freelist;
dc8c34
             freelist = freelist->next;
dc8c34
+            free_it = 0;
dc8c34
         }
dc8c34
         att->namelen = vptr-line;
dc8c34
 		
dc8c34
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
dc8c34
index 0d1fb25..78d4814 100644
dc8c34
--- a/ldap/servers/snmp/main.c
dc8c34
+++ b/ldap/servers/snmp/main.c
dc8c34
@@ -322,6 +322,9 @@ load_config(char *conf_path)
dc8c34
             /* load agentx-master setting */
dc8c34
             p = p + 13;
dc8c34
             if ((p = strtok(p, " \t\n")) != NULL) {
dc8c34
+                if (agentx_master){
dc8c34
+                    free(agentx_master);
dc8c34
+                }
dc8c34
                 if ((agentx_master = (char *) malloc(strlen(p) + 1)) != NULL)
dc8c34
                     strcpy(agentx_master, p);
dc8c34
             }
dc8c34
diff --git a/lib/ldaputil/dbconf.c b/lib/ldaputil/dbconf.c
dc8c34
index 746afc9..e6de3b7 100644
dc8c34
--- a/lib/ldaputil/dbconf.c
dc8c34
+++ b/lib/ldaputil/dbconf.c
dc8c34
@@ -263,7 +263,10 @@ static int dbconf_parse_propval (char *buf, char *ptr,
dc8c34
     /* Success - we have prop & val */
dc8c34
     propval = (DBPropVal_t *)malloc(sizeof(DBPropVal_t));
dc8c34
 
dc8c34
-    if (!propval) return LDAPU_ERR_OUT_OF_MEMORY;
dc8c34
+    if (!propval){
dc8c34
+    	if (encval) free(val);
dc8c34
+        return LDAPU_ERR_OUT_OF_MEMORY;
dc8c34
+    }
dc8c34
     memset((void *)propval, 0, sizeof(DBPropVal_t));
dc8c34
     propval->prop = strdup(prop);
dc8c34
     propval->val = val ? strdup(val) : 0;
dc8c34
@@ -273,7 +276,7 @@ static int dbconf_parse_propval (char *buf, char *ptr,
dc8c34
 	return LDAPU_ERR_OUT_OF_MEMORY;
dc8c34
     }
dc8c34
 
dc8c34
-    if (encval) free(val);	/* val was allocated by dbconf_decodeval */
dc8c34
+    if(encval) free(val);	/* val was allocated by dbconf_decodeval */
dc8c34
 
dc8c34
     insert_dbinfo_propval(db_info, propval);
dc8c34
     return LDAPU_SUCCESS;
dc8c34
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
dc8c34
index 595c1f2..798a926 100644
dc8c34
--- a/lib/libaccess/register.cpp
dc8c34
+++ b/lib/libaccess/register.cpp
dc8c34
@@ -793,6 +793,7 @@ ACL_AttrGetterRegister(NSErr_t *errp, const char *attr, ACLAttrGetterFn_t fn,
dc8c34
     if (*hep == 0) {	/* New entry */
dc8c34
         PR_INIT_CLIST(&getter->list);
dc8c34
         if (NULL == PR_HashTableAdd(ACLAttrGetterHash, attr, (void *)getter)) {
dc8c34
+            FREE(getter);
dc8c34
             ACL_CritExit();
dc8c34
             return -1;
dc8c34
         }
dc8c34
diff --git a/lib/libadmin/error.c b/lib/libadmin/error.c
dc8c34
index c0a1f80..4ba9803 100644
dc8c34
--- a/lib/libadmin/error.c
dc8c34
+++ b/lib/libadmin/error.c
dc8c34
@@ -126,10 +126,13 @@ NSAPI_PUBLIC void output_alert(int type, char *info, char *details, int wait)
dc8c34
     fprintf(stdout, "%s:%s\\n%s", error_headers[type], info, wrapped);
dc8c34
     if(type==FILE_ERROR || type==SYSTEM_ERROR)  {
dc8c34
         err = get_error();
dc8c34
-        if(err != 0)
dc8c34
+        if(err != 0){
dc8c34
+            char *err_str = verbose_error();
dc8c34
             fprintf(stdout,
dc8c34
                         "\\n\\nThe system returned error number %d, "
dc8c34
-                        "which is %s.", err, verbose_error());
dc8c34
+                        "which is %s.", err, err_str);
dc8c34
+            FREE(err_str);
dc8c34
+        }
dc8c34
     }
dc8c34
     fprintf(stdout, "\");");
dc8c34
 
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34