summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-07-18 17:25:08 -0500
committerNoriko Hosoi <nhosoi@redhat.com>2010-08-20 13:03:56 -0700
commit54ec43e2c88e2adc4908a46ebf8770b1b134161e (patch)
tree77203858b1ef2ac3e9651f8e576894ac72d7297a /ldap/servers/slapd
parentac51b2fb3327770890664467c088af4c265ddac7 (diff)
downloadds-54ec43e2c88e2adc4908a46ebf8770b1b134161e.tar.gz
ds-54ec43e2c88e2adc4908a46ebf8770b1b134161e.tar.xz
ds-54ec43e2c88e2adc4908a46ebf8770b1b134161e.zip
Bug 616500 - fix coverify Defect Type: Resource leaks issues CID 12094 - 12136
https://bugzilla.redhat.com/show_bug.cgi?id=616500 Resolves: bug 616500 Bug description: fix coverify Defect Type: Resource leaks issues CID 12114 description: Fixed resource leaks in buildNewModAttribFile().
Diffstat (limited to 'ldap/servers/slapd')
-rw-r--r--ldap/servers/slapd/tools/ldclt/ldapfct.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 658d71d5..aeecf4b9 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -1525,9 +1525,11 @@ buildNewModAttribFile (
LDAPMod attribute; /* To build the attributes */
struct berval *bv = malloc(sizeof(struct berval));
attribute.mod_bvalues = (struct berval **)malloc(2 * sizeof(struct berval *));
+ int rc = 0;
if ((bv == NULL) || (attribute.mod_bvalues == NULL)) {
- return -1;
+ rc = -1;
+ goto error;
}
/*
@@ -1536,8 +1538,11 @@ buildNewModAttribFile (
* to build the rdn of the new entry.
* Note that the random new attribute is also build by this function.
*/
- if (buildRandomRdnOrFilter (tttctx) < 0)
- return (-1);
+ if (buildRandomRdnOrFilter (tttctx) < 0) {
+ rc = -1;
+ goto error;
+ }
+
strcpy (newDn, tttctx->bufFilter);
strcat (newDn, ",");
strcat (newDn, tttctx->bufBaseDN);
@@ -1554,9 +1559,22 @@ buildNewModAttribFile (
attribute.mod_bvalues[0] = bv;
attribute.mod_bvalues[1] = NULL;
- if (addAttrib (attrs, nbAttribs++, &attribute) < 0)
- return (-1);
+ if (addAttrib (attrs, nbAttribs++, &attribute) < 0) {
+ rc = -1;
+ goto error;
+ }
+
+ goto done;
+
+error:
+ if (bv != NULL) {
+ free(bv);
+ }
+ if (attribute.mod_bvalues != NULL) {
+ free(attribute.mod_bvalues);
+ }
+done:
/*
* Normal end
*/