Bug 619122 - fix coverity Defect Type: Memory - Resource Leaks - CID 11975 - 12051
Summary: fix coverity Defect Type: Memory - Resource Leaks - CID 11975 - 12051
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: 389
Classification: Retired
Component: Directory Server
Version: 1.2.7
Hardware: All
OS: All
low
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-28 15:49 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:30 UTC


Attachments (Terms of Use)
0001-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (961 bytes, patch)
2010-07-30 21:02 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0002-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.02 KB, patch)
2010-07-30 21:02 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0003-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.03 KB, patch)
2010-07-30 21:02 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0004-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.15 KB, patch)
2010-07-30 21:03 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0005-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (965 bytes, patch)
2010-07-30 21:03 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0006-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.34 KB, patch)
2010-07-30 21:03 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0007-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1016 bytes, patch)
2010-07-30 21:04 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0008-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (5.20 KB, patch)
2010-07-30 21:04 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0009-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.65 KB, patch)
2010-07-30 21:04 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0010-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (4.33 KB, patch)
2010-07-30 21:05 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0011-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.20 KB, patch)
2010-07-30 21:05 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0012-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.54 KB, patch)
2010-07-30 21:05 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0013-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.22 KB, patch)
2010-07-30 21:06 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0014-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.83 KB, patch)
2010-07-30 21:06 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0015-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.18 KB, patch)
2010-07-30 21:06 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0016-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.12 KB, patch)
2010-07-30 21:07 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0017-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (998 bytes, patch)
2010-07-30 21:07 UTC, Endi Sukma Dewata
nhosoi: review-
Details | Diff
0018-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (964 bytes, patch)
2010-07-30 21:08 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0019-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.04 KB, patch)
2010-07-30 21:08 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0020-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.10 KB, patch)
2010-07-30 21:08 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0021-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.40 KB, patch)
2010-07-30 21:09 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0022-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (4.44 KB, patch)
2010-07-30 21:09 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0023-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.84 KB, patch)
2010-07-30 21:10 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0024-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1018 bytes, patch)
2010-07-30 21:10 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0025-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.10 KB, patch)
2010-07-30 21:11 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0026-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.19 KB, patch)
2010-07-30 21:11 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0027-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (2.81 KB, patch)
2010-07-30 21:11 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0028-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.15 KB, patch)
2010-07-30 21:12 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0029-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.16 KB, patch)
2010-07-30 21:12 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0030-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.16 KB, patch)
2010-07-30 21:13 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0031-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (910 bytes, patch)
2010-07-30 21:13 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0032-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.01 KB, patch)
2010-07-30 21:13 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0033-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.14 KB, patch)
2010-07-30 21:14 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0034-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.46 KB, patch)
2010-07-30 21:14 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0035-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.25 KB, patch)
2010-07-30 21:15 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0036-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.11 KB, patch)
2010-07-30 21:15 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0008a-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (5.17 KB, patch)
2010-08-19 16:28 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0014a-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.76 KB, patch)
2010-08-19 16:29 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0016a-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.96 KB, patch)
2010-08-19 16:33 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff
0037-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch (1.94 KB, patch)
2010-08-19 17:26 UTC, Endi Sukma Dewata
nhosoi: review+
Details | Diff

Description Endi Sukma Dewata 2010-07-28 15:49:23 UTC
fix coverity Defect Type: Memory - Resource Leaks - CID 11975 - 12053

Comment 2 Endi Sukma Dewata 2010-07-30 21:02:00 UTC
Created attachment 435644 [details]
0001-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 3 Endi Sukma Dewata 2010-07-30 21:02:32 UTC
Created attachment 435645 [details]
0002-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 4 Endi Sukma Dewata 2010-07-30 21:02:54 UTC
Created attachment 435646 [details]
0003-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 5 Endi Sukma Dewata 2010-07-30 21:03:13 UTC
Created attachment 435647 [details]
0004-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 6 Endi Sukma Dewata 2010-07-30 21:03:31 UTC
Created attachment 435648 [details]
0005-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 7 Endi Sukma Dewata 2010-07-30 21:03:49 UTC
Created attachment 435649 [details]
0006-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 8 Endi Sukma Dewata 2010-07-30 21:04:06 UTC
Created attachment 435650 [details]
0007-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 9 Endi Sukma Dewata 2010-07-30 21:04:24 UTC
Created attachment 435651 [details]
0008-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 10 Endi Sukma Dewata 2010-07-30 21:04:42 UTC
Created attachment 435652 [details]
0009-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 11 Endi Sukma Dewata 2010-07-30 21:05:00 UTC
Created attachment 435653 [details]
0010-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 12 Endi Sukma Dewata 2010-07-30 21:05:27 UTC
Created attachment 435654 [details]
0011-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 13 Endi Sukma Dewata 2010-07-30 21:05:49 UTC
Created attachment 435655 [details]
0012-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 14 Endi Sukma Dewata 2010-07-30 21:06:07 UTC
Created attachment 435656 [details]
0013-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 15 Endi Sukma Dewata 2010-07-30 21:06:27 UTC
Created attachment 435657 [details]
0014-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 16 Endi Sukma Dewata 2010-07-30 21:06:49 UTC
Created attachment 435658 [details]
0015-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 17 Endi Sukma Dewata 2010-07-30 21:07:28 UTC
Created attachment 435660 [details]
0016-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 18 Endi Sukma Dewata 2010-07-30 21:07:50 UTC
Created attachment 435661 [details]
0017-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 19 Endi Sukma Dewata 2010-07-30 21:08:10 UTC
Created attachment 435662 [details]
0018-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 20 Endi Sukma Dewata 2010-07-30 21:08:32 UTC
Created attachment 435663 [details]
0019-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 21 Endi Sukma Dewata 2010-07-30 21:08:55 UTC
Created attachment 435664 [details]
0020-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 22 Endi Sukma Dewata 2010-07-30 21:09:22 UTC
Created attachment 435665 [details]
0021-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 23 Endi Sukma Dewata 2010-07-30 21:09:44 UTC
Created attachment 435666 [details]
0022-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 24 Endi Sukma Dewata 2010-07-30 21:10:06 UTC
Created attachment 435667 [details]
0023-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 25 Endi Sukma Dewata 2010-07-30 21:10:38 UTC
Created attachment 435668 [details]
0024-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 26 Endi Sukma Dewata 2010-07-30 21:11:12 UTC
Created attachment 435669 [details]
0025-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 27 Endi Sukma Dewata 2010-07-30 21:11:33 UTC
Created attachment 435670 [details]
0026-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 28 Endi Sukma Dewata 2010-07-30 21:11:56 UTC
Created attachment 435671 [details]
0027-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 29 Endi Sukma Dewata 2010-07-30 21:12:17 UTC
Created attachment 435672 [details]
0028-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 30 Endi Sukma Dewata 2010-07-30 21:12:41 UTC
Created attachment 435673 [details]
0029-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 31 Endi Sukma Dewata 2010-07-30 21:13:04 UTC
Created attachment 435674 [details]
0030-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 32 Endi Sukma Dewata 2010-07-30 21:13:25 UTC
Created attachment 435675 [details]
0031-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 33 Endi Sukma Dewata 2010-07-30 21:13:46 UTC
Created attachment 435677 [details]
0032-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 34 Endi Sukma Dewata 2010-07-30 21:14:16 UTC
Created attachment 435678 [details]
0033-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 35 Endi Sukma Dewata 2010-07-30 21:14:42 UTC
Created attachment 435679 [details]
0034-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 36 Endi Sukma Dewata 2010-07-30 21:15:05 UTC
Created attachment 435680 [details]
0035-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 37 Endi Sukma Dewata 2010-07-30 21:15:29 UTC
Created attachment 435681 [details]
0036-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 45 Noriko Hosoi 2010-08-18 21:01:58 UTC
Comment on attachment 435651 [details]
0008-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=11991&streamDefectId=12177&defectInstanceId=14046&fileInstanceId=49276

3652 done:
3653    if (hostport) slapi_ch_free_string(&hostport);
3654    if (ludp) ldap_free_urldesc( ludp );
==>
3652 done:
3653    slapi_ch_free_string(&hostport);
3654    ldap_free_urldesc( ludp );

Comment 51 Noriko Hosoi 2010-08-18 22:01:35 UTC
Comment on attachment 435657 [details]
0014-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=11999&streamDefectId=12185&defectInstanceId=14054&fileInstanceId=49370

slapi_sdn_free calls slapi_sdn_done internally.  We don't need the line 583.
583 slapi_sdn_done(suffix);
584 slapi_sdn_free(&suffix);

Comment 53 Noriko Hosoi 2010-08-18 22:14:39 UTC
Comment on attachment 435660 [details]
0016-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

http://10.16.47.145:8080/sourcebrowser.htm?projectId=10030#mergedDefectId=12001&streamDefectId=12187&defectInstanceId=14058&fileInstanceId=49125

No need to do NULL checks fro slapi_ch_calloc:

 	/* Make a service provider handle */
 	new_sp = (vattr_sp*)slapi_ch_calloc(1,sizeof(vattr_sp));
 	if (NULL == new_sp) {
 		slapd_nasty(sourcefile,7,0);
-		return ENOMEM;
+		rc = ENOMEM;
+		goto error;
 	}
==>

 	/* Make a service provider handle */
 	new_sp = (vattr_sp*)slapi_ch_calloc(1,sizeof(vattr_sp));

 	return_to_caller = (vattr_sp_handle*)slapi_ch_calloc(1,sizeof(vattr_sp_handle));
 	if (NULL == return_to_caller) {
 		slapd_nasty(sourcefile,8,0);
-		return ENOMEM;
+		rc = ENOMEM;
+		goto error;
 	}
==>
 	return_to_caller = (vattr_sp_handle*)slapi_ch_calloc(1,sizeof(vattr_sp_handle));

 	/* Make a handle for the list */
 	list_handle = (vattr_sp_handle*)slapi_ch_calloc(1, sizeof (vattr_sp_handle));
 	if (NULL == list_handle) {
-		return ENOMEM;
+		rc = ENOMEM;
+		goto error;
 	}
==>
 	/* Make a handle for the list */
 	list_handle = (vattr_sp_handle*)slapi_ch_calloc(1, sizeof (vattr_sp_handle));

That being said, we don't need this...
+
+error:
+	slapi_ch_free((void**)&new_sp);
+	return rc;

Comment 54 Noriko Hosoi 2010-08-18 22:17:41 UTC
Comment on attachment 435661 [details]
0017-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

https://bugzilla.redhat.com/show_bug.cgi?id=619122#c53

Comment 74 Endi Sukma Dewata 2010-08-19 16:28:16 UTC
Created attachment 439731 [details]
0008a-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to remove unnecessary NULL checking.

Comment 75 Endi Sukma Dewata 2010-08-19 16:29:48 UTC
Created attachment 439732 [details]
0014a-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to remove unnecessary slapi_sdn_done() invocation.

Comment 76 Endi Sukma Dewata 2010-08-19 16:33:02 UTC
Created attachment 439733 [details]
0016a-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

The patch has been modified to remove unnecessary NULL checking.

Comment 77 Endi Sukma Dewata 2010-08-19 17:26:25 UTC
Created attachment 439740 [details]
0037-Bug-619122-fix-coverify-Defect-Type-Resource-leaks-i.patch

Comment 82 Noriko Hosoi 2010-08-19 21:33:10 UTC
On behalf of Endi (edewata@redhat.com), pushed to master.

$ git merge endi
Updating 5d578b8..92ee0f5
Fast-forward
 ldap/servers/plugins/acl/acl_ext.c                 |   20 +++++---
 ldap/servers/plugins/acl/acllas.c                  |   47 ++++++++++---------
 ldap/servers/plugins/chainingdb/cb_instance.c      |    5 +-
 ldap/servers/plugins/cos/cos_cache.c               |    2 +-
 ldap/servers/plugins/dna/dna.c                     |    6 ++-
 ldap/servers/plugins/passthru/ptconfig.c           |   41 ++++++++++++-----
 ldap/servers/plugins/replication/cl5_api.c         |   21 +++++---
 .../servers/plugins/replication/repl5_connection.c |   26 +++++------
 ldap/servers/plugins/replication/repl5_protocol.c  |    8 ++-
 .../plugins/replication/repl5_protocol_util.c      |    2 +-
 ldap/servers/plugins/replication/repl5_replica.c   |    2 +
 ldap/servers/plugins/replication/repl5_ruv.c       |   18 ++-----
 .../plugins/replication/repl5_tot_protocol.c       |    7 +++-
 ldap/servers/plugins/replication/repl_compare.c    |    1 +
 ldap/servers/plugins/replication/urp.c             |    1 +
 .../plugins/replication/windows_connection.c       |    1 +
 ldap/servers/slapd/csngen.c                        |    2 +
 ldap/servers/slapd/entry.c                         |   31 +++++++++++--
 ldap/servers/slapd/factory.c                       |    1 +
 ldap/servers/slapd/log.c                           |    2 +
 ldap/servers/slapd/mapping_tree.c                  |    2 +-
 ldap/servers/slapd/plugin.c                        |    2 +
 ldap/servers/slapd/pw.c                            |    4 +-
 ldap/servers/slapd/vattr.c                         |   17 ++-----
 lib/libaccess/oneeval.cpp                          |    2 +
 25 files changed, 165 insertions(+), 106 deletions(-)

$ git push
Counting objects: 275, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (237/237), done.
Writing objects: 100% (237/237), 23.44 KiB, done.
Total 237 (delta 200), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
   5d578b8..92ee0f5  master -> master


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