Bug 617630 - fix coverity Defect Type: Resource leaks issues CID 12052 - 12093
Summary: fix coverity Defect Type: Resource leaks issues CID 12052 - 12093
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: 389
Classification: Retired
Component: Directory Server
Version: 1.2.7
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Rich Megginson
QA Contact: Chandrasekar Kannan
URL:
Whiteboard:
Depends On:
Blocks: 389_1.2.7 639035
TreeView+ depends on / blocked
 
Reported: 2010-07-23 15:26 UTC by Endi Sukma Dewata
Modified: 2015-01-04 23:43 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-05-17 14:08:18 UTC


Attachments (Terms of Use)
0001-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (3.14 KB, patch)
2010-07-27 17:31 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0002-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.66 KB, patch)
2010-07-27 17:32 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0003-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.31 KB, patch)
2010-07-27 17:32 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0004-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.99 KB, patch)
2010-07-27 17:33 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0005-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (7.51 KB, patch)
2010-07-27 17:33 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0006-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.08 KB, patch)
2010-07-27 17:33 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0007-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.52 KB, patch)
2010-07-27 17:33 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0008-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.12 KB, patch)
2010-07-27 17:34 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0009-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.73 KB, patch)
2010-07-27 17:34 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0010-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.20 KB, patch)
2010-07-27 17:34 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0011-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (3.51 KB, patch)
2010-07-27 17:35 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0012-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.45 KB, patch)
2010-07-27 17:35 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0013-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (3.63 KB, patch)
2010-07-27 17:35 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0014-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.29 KB, patch)
2010-07-27 17:36 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0015-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.31 KB, patch)
2010-07-27 17:36 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0016-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (3.59 KB, patch)
2010-07-27 17:36 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0017-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.71 KB, patch)
2010-07-27 17:37 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0018-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.21 KB, patch)
2010-07-27 17:37 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0019-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (3.90 KB, patch)
2010-07-27 17:37 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0020-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.60 KB, patch)
2010-07-27 17:38 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0021-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.10 KB, patch)
2010-07-27 17:38 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0022-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.58 KB, patch)
2010-07-27 17:38 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
defect id 12062 (2.20 KB, patch)
2010-08-17 16:02 UTC, Noriko Hosoi
no flags Details | Diff
coverity 12062 (3.52 MB, patch)
2010-08-17 16:49 UTC, Noriko Hosoi
rmeggins: review+
Details | Diff
0002a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.98 KB, patch)
2010-08-18 19:29 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0004a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.30 KB, patch)
2010-08-18 19:30 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0007a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.70 KB, patch)
2010-08-18 19:34 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0010a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.62 KB, patch)
2010-08-18 19:36 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0011a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (3.46 KB, patch)
2010-08-18 19:41 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0013a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (4.21 KB, patch)
2010-08-18 19:43 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0018a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.02 KB, patch)
2010-08-18 19:45 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0020a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.58 KB, patch)
2010-08-18 19:46 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0023-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.85 KB, patch)
2010-08-19 22:36 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0024-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.97 KB, patch)
2010-08-19 23:17 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff

Description Endi Sukma Dewata 2010-07-23 15:26:38 UTC
fix coverity Defect Type: Resource leaks issues CID 12052 - 12093

Comment 2 Endi Sukma Dewata 2010-07-27 17:31:58 UTC
Created attachment 434764 [details]
0001-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 3 Endi Sukma Dewata 2010-07-27 17:32:20 UTC
Created attachment 434765 [details]
0002-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 4 Endi Sukma Dewata 2010-07-27 17:32:43 UTC
Created attachment 434766 [details]
0003-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 5 Endi Sukma Dewata 2010-07-27 17:33:01 UTC
Created attachment 434767 [details]
0004-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 6 Endi Sukma Dewata 2010-07-27 17:33:16 UTC
Created attachment 434768 [details]
0005-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 7 Endi Sukma Dewata 2010-07-27 17:33:32 UTC
Created attachment 434769 [details]
0006-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 8 Endi Sukma Dewata 2010-07-27 17:33:47 UTC
Created attachment 434770 [details]
0007-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 9 Endi Sukma Dewata 2010-07-27 17:34:08 UTC
Created attachment 434771 [details]
0008-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 10 Endi Sukma Dewata 2010-07-27 17:34:29 UTC
Created attachment 434772 [details]
0009-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 11 Endi Sukma Dewata 2010-07-27 17:34:56 UTC
Created attachment 434773 [details]
0010-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 12 Endi Sukma Dewata 2010-07-27 17:35:15 UTC
Created attachment 434774 [details]
0011-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 13 Endi Sukma Dewata 2010-07-27 17:35:36 UTC
Created attachment 434775 [details]
0012-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 14 Endi Sukma Dewata 2010-07-27 17:35:57 UTC
Created attachment 434776 [details]
0013-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 15 Endi Sukma Dewata 2010-07-27 17:36:15 UTC
Created attachment 434777 [details]
0014-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 16 Endi Sukma Dewata 2010-07-27 17:36:33 UTC
Created attachment 434778 [details]
0015-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 17 Endi Sukma Dewata 2010-07-27 17:36:51 UTC
Created attachment 434779 [details]
0016-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 18 Endi Sukma Dewata 2010-07-27 17:37:11 UTC
Created attachment 434780 [details]
0017-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 19 Endi Sukma Dewata 2010-07-27 17:37:27 UTC
Created attachment 434781 [details]
0018-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 20 Endi Sukma Dewata 2010-07-27 17:37:47 UTC
Created attachment 434782 [details]
0019-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 21 Endi Sukma Dewata 2010-07-27 17:38:10 UTC
Created attachment 434783 [details]
0020-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 22 Endi Sukma Dewata 2010-07-27 17:38:28 UTC
Created attachment 434784 [details]
0021-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 23 Endi Sukma Dewata 2010-07-27 17:38:52 UTC
Created attachment 434785 [details]
0022-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 25 Noriko Hosoi 2010-08-17 00:10:22 UTC
Comment on attachment 434765 [details]
0002-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12053&streamDefectId=12239&defectInstanceId=14124&fileInstanceId=49541

0002-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Since Private_Repl_Protocol prp is not initialized with NULL, prp->private is not NULL when jumped to lower from the line 1576 or 1580.
1560        Private_Repl_Protocol *prp = (Private_Repl_Protocol *)slapi_ch_malloc(sizeof(Private_Repl_Protocol));

prp->private should be initialized between the line 1560 and 1576.  Otherwise, some garbage address could be passed to this free:

+        slapi_ch_free((void **)&(*prpp)->private);

Comment 27 Noriko Hosoi 2010-08-17 00:18:59 UTC
Comment on attachment 434767 [details]
0004-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12055&streamDefectId=12241&defectInstanceId=14126&fileInstanceId=49546

0004-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Since Private_Repl_Protocol prp is not initialized with NULL, prp->private is not NULL when jumped to lower from the line 330 or 334.
 314        Private_Repl_Protocol *prp = (Private_Repl_Protocol *)slapi_ch_malloc(sizeof(Private_Repl_Protocol));

prp->private should be initialized between the line 314 and 330.  Otherwise, some garbage address could be passed to this free:

+        slapi_ch_free((void **)&(*prpp)->private);

Comment 28 Noriko Hosoi 2010-08-17 00:27:40 UTC
Comment on attachment 434767 [details]
0004-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12056&streamDefectId=12242&defectInstanceId=14127&fileInstanceId=49546

This part is good:
@@ -244,6 +244,7 @@ done:
 	}
 	
 	prp->stopped = 1;
+	ruv_destroy(&ruv);
 	LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_tot_run\n" );
 }

Comment 34 Noriko Hosoi 2010-08-17 16:02:54 UTC
Created attachment 439148 [details]
defect id 12062

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12062&streamDefectId=12248&defectInstanceId=14133&fileInstanceId=49287

Comment:
get rid of the unused functions from plugins/shared/{utils.c,plugin_utils.h}.

Comment 35 Noriko Hosoi 2010-08-17 16:28:46 UTC
Comment on attachment 439148 [details]
defect id 12062

(In reply to comment #34)
> Created attachment 439148 [details]
> defect id 12062
> 
> http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12062&streamDefectId=12248&defectInstanceId=14133&fileInstanceId=49287
> 
> Comment:
> get rid of the unused functions from plugins/shared/{utils.c,plugin_utils.h}.

Sorry.  It was a wrong attachment...

Comment 36 Noriko Hosoi 2010-08-17 16:49:55 UTC
Created attachment 439162 [details]
coverity 12062

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12062&streamDefectId=12248&defectInstanceId=14133&fileInstanceId=49287

Comment:
coverity 12062
. Getting rid of unused functions from plugins/shared/utils.c.
. Moving plugins/shared/{utils.c,plugin-utils.h} to uiduniq.

Comment 37 Noriko Hosoi 2010-08-17 17:28:36 UTC
Comment on attachment 434770 [details]
0007-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12064&streamDefectId=12250&defectInstanceId=14135&fileInstanceId=49577

0007-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Not just these memories, but also other allocated memories in this function should be freed.
  745        altany = (char **)slapi_ch_calloc(anysize + 1, sizeof(char *));
  746        oaltany = (char **)slapi_ch_calloc(anysize + 1, sizeof(char *));

diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index 18e7a05..3ca7416 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -688,11 +688,15 @@ string_assertion2keys_sub(
 	int localsublens[3] = {SUBBEGIN, SUBMIDDLE, SUBEND};/* default values */
 	int maxsublen;
 	char	*comp_buf = NULL;
+	/* altinit|any|final: store alt string from value_normalize_ext if any,
+	 * otherwise the original string.  And used for the real job */
 	char *altinit = NULL;
-	char *oaltinit = NULL;
 	char **altany = NULL;
-	char **oaltany = NULL;
 	char *altfinal = NULL;
+	/* oaltinit|any|final: prepared to free altinit|any|final if allocated in 
+	 * value_normalize_ext */
+	char *oaltinit = NULL;
+	char **oaltany = NULL;
 	char *oaltfinal = NULL;
 	int anysize = 0;
 
@@ -776,7 +780,7 @@ string_assertion2keys_sub(
 		}
 	}
 	if ( nsubs == 0 ) {	/* no keys to return */
-		return( 0 );
+		goto done;
 	}
 
 	/*
@@ -795,7 +799,6 @@ string_assertion2keys_sub(
 		substring_comp_keys( ivals, &nsubs, altinit, initiallen, '^', syntax,
 							 comp_buf, substrlens );
 	}
-	slapi_ch_free_string(&oaltinit);
 	for ( i = 0; altany != NULL && altany[i] != NULL; i++ ) {
 		len = strlen( altany[i] );
 		if ( len < substrlens[INDEX_SUBSTRMIDDLE] ) {
@@ -803,18 +806,22 @@ string_assertion2keys_sub(
 		}
 		substring_comp_keys( ivals, &nsubs, altany[i], len, 0, syntax,
 							 comp_buf, substrlens );
-		slapi_ch_free_string(&oaltany[i]);
 	}
-	slapi_ch_free((void **)&oaltany);
-	slapi_ch_free((void **)&altany);
 	if ( altfinal != NULL ) {
 		substring_comp_keys( ivals, &nsubs, altfinal, finallen, '$', syntax,
 							 comp_buf, substrlens );
 	}
-	slapi_ch_free_string(&oaltfinal);
 	(*ivals)[nsubs] = NULL;
-	slapi_ch_free_string(&comp_buf);
 
+done:
+	slapi_ch_free_string(&oaltinit);
+	slapi_ch_free_string(&oaltfinal);
+	for ( i = 0; altany != NULL && altany[i] != NULL; i++ ) {
+		slapi_ch_free_string(&oaltany[i]);
+	}
+	slapi_ch_free((void **)&oaltany);
+	slapi_ch_free((void **)&altany);
+	slapi_ch_free_string(&comp_buf);
 	return( 0 );
 }

Comment 43 Noriko Hosoi 2010-08-17 18:06:55 UTC
Comment on attachment 434773 [details]
0010-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12071&streamDefectId=12257&defectInstanceId=14142&fileInstanceId=49343

0010-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Since it's a good chance, we could get rid of useless NULL checking for slapi_ch_.*alloc functions. 
Also, no need to take care any more, but since you touched the inside of #if defined (_WIN32), we could avoid the invalid free of priv->memory for Windows.

diff --git a/ldap/servers/slapd/back-ldbm/perfctrs.c b/ldap/servers/slapd/back-ldbm/perfctrs.c
index 5b7c68f..4f5361c 100644
--- a/ldap/servers/slapd/back-ldbm/perfctrs.c
+++ b/ldap/servers/slapd/back-ldbm/perfctrs.c
@@ -176,12 +176,12 @@ void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
 	 * On Windows, the performance counters reside in shared memory.
 	 */
 	if (NULL == instance_name) {
-		return;
+		goto error;
 	}
 	/* Invent the name for the shared memory region */
 	string = string_concatenate(instance_name,PERFCTRS_REGION_SUFFIX);
 	if (NULL == string) {
-		return;
+		goto error;
 	}
 #endif
 
@@ -189,9 +189,6 @@ void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
 	 * We need the perfctrs_private area on all platforms.
 	 */
 	priv = (perfctrs_private *)slapi_ch_calloc(1,sizeof(perfctrs_private));
-	if (NULL == priv) {
-		return;
-	}
 
 #if defined(_WIN32)
 	/* Try to open the shared memory region */
@@ -200,7 +197,7 @@ void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
 	/* Invent the name for the update mutex */
 	string = string_concatenate(instance_name,PERFCTRS_MUTEX_SUFFIX);
 	if (NULL == string) {
-		return;
+		goto error;
 	}
 	open_event(string,priv);
 	free(string);
@@ -210,12 +207,17 @@ void perfctrs_init(struct ldbminfo *li, perfctrs_private **ret_priv)
 	/*
 	 * On other platforms, the performance counters reside in regular memory.
 	 */
-	if ( NULL == ( priv->memory = slapi_ch_calloc( 1, sizeof( performance_counters )))) {
-		return;
-	}
+	priv->memory = slapi_ch_calloc( 1, sizeof( performance_counters ));
 #endif
 
 	*ret_priv = priv;
+	return;
+
+error:
+#if !defined(_WIN32)
+	if (priv) slapi_ch_free((void**)&priv->memory);
+#endif
+	slapi_ch_free((void**)&priv);
 }
 
 /* Terminate perf ctrs */

Comment 47 Noriko Hosoi 2010-08-17 18:35:42 UTC
Comment on attachment 434776 [details]
0013-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12075&streamDefectId=12261&defectInstanceId=14146&fileInstanceId=49314

0013-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

About this diff:
https://bugzilla.redhat.com/attachment.cgi?id=434776&action=diff#a/ldap/servers/slapd/back-ldbm/import-merge.c_sec1

We could just remove the useless NULL checking
diff --git a/ldap/servers/slapd/back-ldbm/import-merge.c b/ldap/servers/slapd/back-ldbm/import-merge.c
index 477320d..c99ac19 100644
--- a/ldap/servers/slapd/back-ldbm/import-merge.c
+++ b/ldap/servers/slapd/back-ldbm/import-merge.c
@@ -128,17 +128,11 @@ static import_merge_queue_entry *import_merge_make_new_queue_entry(import_merge_
     /* Make a new entry */
     import_merge_queue_entry *new_entry = (import_merge_queue_entry *)slapi_ch_calloc(1, sizeof(import_merge_queue_entry));
 
-    if (NULL == new_entry) {
-        return NULL;
-    }
     new_entry->key = *key;
     new_entry->thang = *thang;
     new_entry->file_referenced_list =
         (int *)slapi_ch_calloc(passes, sizeof(fileno));
 
-    if (NULL == new_entry->file_referenced_list) {
-        return NULL;
-    }
     (new_entry->file_referenced_list)[fileno] = 1;
     return new_entry;
 }

Comment 48 Noriko Hosoi 2010-08-17 19:23:39 UTC
Comment on attachment 434776 [details]
0013-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12076&streamDefectId=12262&defectInstanceId=14147&fileInstanceId=49314

0013-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The proposed fix could make coverity happy, but it still leaves leaks: not just memory, but also possible DB handle and DB cursor leaks.  But cleaning them up is not too important.  If import fails, the DB is corrupted and we have to recover it anyway.  If the import is running as an online-mode, the server should be shutdown and the DB must be recovered (by retrying offline import).
@@ -643,6 +638,12 @@ static int import_merge_one_file(ImportWorkerInfo *worker,
     }
 
 error:
+    if (ret) {
+        import_log_notice(worker->job, "%s: Import merge failed. "
+                          "If this is an online-import, shutdown the server "
+                          "and try the offline command line import (ldif2db)"
+                          inst_name);
+    }
     return ret;
 }

Comment 53 Noriko Hosoi 2010-08-17 21:13:51 UTC
Comment on attachment 434774 [details]
0011-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12089&streamDefectId=12275&defectInstanceId=14160&fileInstanceId=49315

0011-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

slapi_ch_free(_string) takes NULL input.  We don't need the NULL checking.

1274        if (data.data) slapi_ch_free(&(data.data));
1309        if (ecopy) slapi_ch_free_string((void**)&ecopy);

1717    done:
1718        if (ecopy) slapi_ch_free_string((void**)&ecopy);
1719        if (data.data) slapi_ch_free(&(data.data));
==>
1274        slapi_ch_free(&(data.data));
1309        slapi_ch_free_string((void**)&ecopy);

1717    done:
1718        slapi_ch_free_string((void**)&ecopy);
1719        slapi_ch_free(&(data.data));

Comment 55 Noriko Hosoi 2010-08-17 21:47:46 UTC
Comment on attachment 434781 [details]
0018-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The change made to the line 573 is not needed; the macro IDL_NIDS does the check.
572     LDAPDebug( LDAP_DEBUG_TRACE, "<= range_candidates %lu\n",
573         idl ? (u_long)IDL_NIDS(idl) : 0, 0, 0 );

#define IDL_NIDS(idl)           (idl ? (idl)->b_nids : (NIDS)0)

Comment 59 Noriko Hosoi 2010-08-17 22:26:43 UTC
Comment on attachment 434783 [details]
0020-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12090&streamDefectId=12276&defectInstanceId=14162&fileInstanceId=48986

valuearray_free takes NULL input.
528    if (valuestoadd) valuearray_free(&valuestoadd);
==>
528    valuearray_free(&valuestoadd);

Comment 61 Endi Sukma Dewata 2010-08-18 19:29:04 UTC
Created attachment 439478 [details]
0002a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to initialize prp right after creation.

Comment 62 Endi Sukma Dewata 2010-08-18 19:30:20 UTC
Created attachment 439479 [details]
0004a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to initialize prp right after creation.

Comment 63 Endi Sukma Dewata 2010-08-18 19:34:03 UTC
Created attachment 439480 [details]
0007a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to release all other allocated memories in string_assertion2keys_sub().

Comment 64 Endi Sukma Dewata 2010-08-18 19:36:38 UTC
Created attachment 439482 [details]
0010a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to remove unnecessary NULL checking and fix invalid free for Windows.

Comment 65 Endi Sukma Dewata 2010-08-18 19:41:22 UTC
Created attachment 439484 [details]
0011a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to remove unnecessary NULL checking.

Comment 66 Endi Sukma Dewata 2010-08-18 19:43:24 UTC
Created attachment 439485 [details]
0013a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to remove unnecessary NULL checking and log a message when an error occurs.

Comment 67 Endi Sukma Dewata 2010-08-18 19:45:00 UTC
Created attachment 439488 [details]
0018a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to remove unnecessary NULL checking.

Comment 68 Endi Sukma Dewata 2010-08-18 19:46:33 UTC
Created attachment 439490 [details]
0020a-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to remove unnecessary NULL checking.

Comment 69 Endi Sukma Dewata 2010-08-19 22:36:34 UTC
Created attachment 439814 [details]
0023-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 73 Endi Sukma Dewata 2010-08-19 23:17:18 UTC
Created attachment 439819 [details]
0024-Bug-617630-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 81 Noriko Hosoi 2010-08-20 00:06:36 UTC
On behalf of Endi (edewata@redhat.com), pushed to master.

$ git merge endi
Updating 92ee0f5..634c7aa
Fast-forward
 Makefile.am                                        |    4 +-
 Makefile.in                                        | 4421 ++--
 aclocal.m4                                         | 6884 +----
 compile                                            |   21 +-
 config.guess                                       |  302 +-
 config.h.in                                        |   12 +-
 config.sub                                         |  232 +-
 configure                                          |39022 ++++++++------------
 depcomp                                            |  172 +-
 install-sh                                         |  517 +-
 .../plugins/replication/windows_connection.c       |   27 +-
 .../plugins/replication/windows_inc_protocol.c     |   18 +-
 ldap/servers/plugins/replication/windows_private.c |    1 +
 .../plugins/replication/windows_tot_protocol.c     |   23 +-
 ldap/servers/plugins/rever/des.c                   |   72 +-
 ldap/servers/plugins/rever/rever.c                 |    8 +-
 ldap/servers/plugins/shared/utils.c                |  508 -
 ldap/servers/plugins/syntaxes/string.c             |   25 +-
 .../plugins/{shared => uiduniq}/plugin-utils.h     |   16 -
 ldap/servers/plugins/uiduniq/utils.c               |  254 +
 ldap/servers/plugins/usn/usn.c                     |    1 +
 ldap/servers/plugins/usn/usn_cleanup.c             |    1 +
 ldap/servers/slapd/back-ldbm/filterindex.c         |   10 +-
 ldap/servers/slapd/back-ldbm/id2entry.c            |   16 +-
 ldap/servers/slapd/back-ldbm/idl.c                 |   15 +-
 ldap/servers/slapd/back-ldbm/import-merge.c        |   28 +-
 ldap/servers/slapd/back-ldbm/import-threads.c      |   21 +-
 ldap/servers/slapd/back-ldbm/index.c               |   17 +-
 ldap/servers/slapd/back-ldbm/instance.c            |   31 +-
 ldap/servers/slapd/back-ldbm/ldbm_index_config.c   |    8 +-
 ldap/servers/slapd/back-ldbm/ldif2ldbm.c           |    4 +-
 ldap/servers/slapd/back-ldbm/perfctrs.c            |   24 +-
 ldap/servers/slapd/back-ldbm/vlv.c                 |   47 +-
 ldap/servers/slapd/entrywsi.c                      |    4 +-
 ldap/servers/slapd/plugin.c                        |    7 +-
 ldap/servers/slapd/util.c                          |   10 +-
 lib/ldaputil/certmap.c                             |   30 +-
 ltmain.sh                                          |13199 ++++---
 missing                                            |  104 +-
 39 files changed, 27784 insertions(+), 38332 deletions(-)
 delete mode 100644 ldap/servers/plugins/shared/utils.c
 rename ldap/servers/plugins/{shared => uiduniq}/plugin-utils.h (86%)
 create mode 100644 ldap/servers/plugins/uiduniq/utils.c
 mode change 100644 => 100755 ltmain.sh

$ git push
Counting objects: 232, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (180/180), done.
Writing objects: 100% (183/183), 204.48 KiB, done.
Total 183 (delta 147), reused 7 (delta 3)
To ssh://git.fedorahosted.org/git/389/ds.git
   92ee0f5..634c7aa  master -> master

Comment 85 Noriko Hosoi 2010-08-26 06:30:27 UTC
Undo the commit e23c8bd9994d5592738cb44e1c2b426aba7fbd4a

$ git merge work
Updating d6f0a9e..50aff56
Fast-forward
 ldap/servers/slapd/entrywsi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

$ git push
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 737 bytes, done.
Total 6 (delta 4), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
   d6f0a9e..50aff56  master -> master

Bug description: CID 12090 was a false positive
description: Undo the commit e23c8bd9994d5592738cb44e1c2b426aba7fbd4a


Note You need to log in before you can comment on or make changes to this bug.