From 3fe6ca1c189f43e8e9f7059943ab7e2939c7582e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 2 Jul 2005 18:43:22 +0000 Subject: r8084: do not leak memory on errors (This used to be commit 2e328e6c2fc2c66b0d0de910cd43ab232049bc90) --- source4/lib/ldb/common/ldb_dn.c | 2 +- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'source4') 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 #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; -- cgit