summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/back-ldbm
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-07-26 16:22:07 -0500
committerNoriko Hosoi <nhosoi@redhat.com>2010-08-19 17:01:36 -0700
commitd4faa7612b9c5f0d05a6380ef807e27b53620d0d (patch)
treef9c3075dd20a4d5adac974d8b00d80adb66b0d3e /ldap/servers/slapd/back-ldbm
parent164afc5501d66bb0f6677c7bf85abd162c6f81ee (diff)
downloadds-d4faa7612b9c5f0d05a6380ef807e27b53620d0d.tar.gz
ds-d4faa7612b9c5f0d05a6380ef807e27b53620d0d.tar.xz
ds-d4faa7612b9c5f0d05a6380ef807e27b53620d0d.zip
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 12070. description: The idl_old_store_block() has been modified to release the master_block when an error occurs.
Diffstat (limited to 'ldap/servers/slapd/back-ldbm')
-rw-r--r--ldap/servers/slapd/back-ldbm/idl.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/ldap/servers/slapd/back-ldbm/idl.c b/ldap/servers/slapd/back-ldbm/idl.c
index ca370768..18767e77 100644
--- a/ldap/servers/slapd/back-ldbm/idl.c
+++ b/ldap/servers/slapd/back-ldbm/idl.c
@@ -1080,6 +1080,7 @@ int idl_old_store_block(
struct ldbminfo *li = (struct ldbminfo *) be->be_database->plg_private;
int ret = 0;
idl_private *priv = a->ai_idl;
+ IDList *master_block = NULL;
if (0 == a->ai_idl->idl_maxids) {
idl_init_maxids(li,a->ai_idl);
@@ -1107,7 +1108,6 @@ int idl_old_store_block(
size_t number_of_cont_blks = 0;
size_t i = 0;
size_t number_of_ids_left = 0;
- IDList *master_block = NULL;
size_t index = 0;
DBT cont_key = {0};
@@ -1123,7 +1123,8 @@ int idl_old_store_block(
/* Alloc master block */
master_block = idl_alloc(number_of_cont_blks + 1);
if (NULL == master_block) {
- return -1;
+ ret = -1;
+ goto done;
}
master_block->b_nids = INDBLOCK;
master_block->b_ids[number_of_cont_blks] = NOID;
@@ -1142,7 +1143,8 @@ int idl_old_store_block(
}
this_cont_block = idl_alloc(size_of_this_block);
if (NULL == this_cont_block) {
- return -1;
+ ret = -1;
+ goto done;
}
this_cont_block->b_nids = size_of_this_block;
/* Copy over the ids to the cont block we're making */
@@ -1158,7 +1160,7 @@ int idl_old_store_block(
if ( ret != 0 && ret != DB_LOCK_DEADLOCK )
{
LDAPDebug( LDAP_DEBUG_ANY, "idl_store_block(%s) 1 BAD %d %s\n",key->data, ret, dblayer_strerror( ret ));
- return ret;
+ goto done;
}
/* Put the lead ID number in the header block */
master_block->b_ids[i] = lead_id;
@@ -1170,11 +1172,12 @@ int idl_old_store_block(
PR_ASSERT(0 == number_of_ids_left);
/* Now store the master block */
ret = idl_store(be,db,key,master_block,txn);
- /* And free it */
- idl_free(master_block);
}
}
}
+done:
+ /* Free master block */
+ idl_free(master_block);
return ret;
}