Author: idra
Date: 2005-07-02 18:43:22 +0000 (Sat, 02 Jul 2005)
New Revision: 8084

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8084

Log:
do not leak memory on errors
Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c   2005-07-02 18:34:13 UTC 
(rev 8083)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c   2005-07-02 18:43:22 UTC 
(rev 8084)
@@ -37,8 +37,8 @@
 #include "includes.h"
 #include "ldb/include/ldb.h"
 #include "ldb/include/ldb_private.h"
+#include <ctype.h>
 
-
 #define LDB_DN_NULL_FAILED(x) if (!(x)) goto failed
 
 static int ldb_dn_is_valid_attribute_name(const char *name)

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2005-07-02 18:34:13 UTC 
(rev 8083)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2005-07-02 18:43:22 UTC 
(rev 8084)
@@ -56,6 +56,8 @@
        TDB_DATA key;
        char *key_str = NULL;
        char *dn_folded = NULL;
+       struct ldb_dn *edn = NULL;
+       struct ldb_dn *cedn = NULL;
 
        /*
          most DNs are case insensitive. The exception is index DNs for
@@ -71,8 +73,6 @@
        if (*dn == '@') {
                dn_folded = talloc_strdup(ldb, dn);
        } else {
-               struct ldb_dn *edn, *cedn;
-
                edn = ldb_dn_explode(ldb, dn);
                if (!edn)
                        goto failed;
@@ -89,10 +89,6 @@
                talloc_free(cedn);
        }
 
-       if (!dn_folded) {
-               goto failed;
-       }
-
        key_str = talloc_asprintf(ldb, "DN=%s", dn_folded);
        talloc_free(dn_folded);
 
@@ -101,11 +97,13 @@
        }
 
        key.dptr = key_str;
-       key.dsize = strlen(key_str)+1;
+       key.dsize = strlen(key_str) + 1;
 
        return key;
 
 failed:
+       talloc_free(edn);
+       talloc_free(cedn);
        errno = ENOMEM;
        key.dptr = NULL;
        key.dsize = 0;

Reply via email to