summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-07-02 18:43:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:07 -0500
commit3fe6ca1c189f43e8e9f7059943ab7e2939c7582e (patch)
tree5b409b04fb8ecc45db4cb8ebc463680d6bc0b1a7
parente6b353e7640dcc98cd6d519cee1d5ff42e8c676f (diff)
downloadsamba-3fe6ca1c189f43e8e9f7059943ab7e2939c7582e.tar.gz
samba-3fe6ca1c189f43e8e9f7059943ab7e2939c7582e.tar.bz2
samba-3fe6ca1c189f43e8e9f7059943ab7e2939c7582e.zip
r8084: do not leak memory on errors
(This used to be commit 2e328e6c2fc2c66b0d0de910cd43ab232049bc90)
-rw-r--r--source4/lib/ldb/common/ldb_dn.c2
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c12
2 files changed, 6 insertions, 8 deletions
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 8b9cf4e129..7556a144e2 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -37,7 +37,7 @@
#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
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index eb72e665f5..df94b0691d 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -56,6 +56,8 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn)
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 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn)
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 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn)
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 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn)
}
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;