summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-07-26 11:41:10 -0500
committerNoriko Hosoi <nhosoi@redhat.com>2010-08-19 17:00:21 -0700
commitfb4aba33e0779f4d7d4b5752528e5b8054be93ec (patch)
treef55188ea36c8abcb45ad906a715a8f3cfe5bda87
parent9632226671eea6b8d6397f4560344d95136de45b (diff)
Bug 617630 - fix coverify Defect Type: Resource leaks issues CID 12052 - 12093
https://bugzilla.redhat.com/show_bug.cgi?id=617630 Resolves: bug 617630 Bug description: fix coverify Defect Type: Resource leaks issues CID 12077 description: id2entry_add_ext() has been modified to release resources properly.
-rw-r--r--ldap/servers/slapd/back-ldbm/id2entry.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/ldap/servers/slapd/back-ldbm/id2entry.c b/ldap/servers/slapd/back-ldbm/id2entry.c
index 31d3b724..235fd68b 100644
--- a/ldap/servers/slapd/back-ldbm/id2entry.c
+++ b/ldap/servers/slapd/back-ldbm/id2entry.c
@@ -67,7 +67,8 @@ id2entry_add_ext( backend *be, struct backentry *e, back_txn *txn, int encrypt
if ( (rc = dblayer_get_id2entry( be, &db )) != 0 ) {
LDAPDebug( LDAP_DEBUG_ANY, "Could not open/create id2entry\n",
0, 0, 0 );
- return( -1 );
+ rc = -1;
+ goto done;
}
id_internal_to_stored(e->ep_id,temp_id);
@@ -82,7 +83,8 @@ id2entry_add_ext( backend *be, struct backentry *e, back_txn *txn, int encrypt
if (rc) {
LDAPDebug( LDAP_DEBUG_ANY, "attrcrypt_encrypt_entry failed in id2entry_add\n",
0, 0, 0 );
- return ( -1 );
+ rc = -1;
+ goto done;
}
}
@@ -111,10 +113,6 @@ id2entry_add_ext( backend *be, struct backentry *e, back_txn *txn, int encrypt
}
data.dptr = slapi_entry2str_with_options(entry_to_use, &len, options);
data.dsize = len + 1;
- /* If we had an encrypted entry, we no longer need it */
- if (encrypted_entry) {
- backentry_free(&encrypted_entry);
- }
}
if (NULL != txn) {
@@ -147,6 +145,12 @@ id2entry_add_ext( backend *be, struct backentry *e, back_txn *txn, int encrypt
(void) CACHE_ADD( &inst->inst_cache, e, NULL );
}
+done:
+ /* If we had an encrypted entry, we no longer need it */
+ if (encrypted_entry) {
+ backentry_free(&encrypted_entry);
+ }
+
LDAPDebug( LDAP_DEBUG_TRACE, "<= id2entry_add %d\n", rc, 0, 0 );
return( rc );
}