summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2001-12-10 06:09:42 +0000
committerMartin Pool <mbp@samba.org>2001-12-10 06:09:42 +0000
commita228c7efcc06b901ca51a6da77f8a52b77912f55 (patch)
treedfab51a1bcc74bf7a5cd388977c0193bbcd21568
parent217c39f23282e20f96a61a0d5a2434b3f5f66a86 (diff)
downloadsamba-a228c7efcc06b901ca51a6da77f8a52b77912f55.tar.gz
samba-a228c7efcc06b901ca51a6da77f8a52b77912f55.tar.xz
samba-a228c7efcc06b901ca51a6da77f8a52b77912f55.zip
Allocate tdb name up front in case log functions want to use it.
-rw-r--r--source/tdb/tdb.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/source/tdb/tdb.c b/source/tdb/tdb.c
index de376d29b20..1ca29745911 100644
--- a/source/tdb/tdb.c
+++ b/source/tdb/tdb.c
@@ -1422,6 +1422,11 @@ TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags,
tdb->flags = tdb_flags;
tdb->open_flags = open_flags;
tdb->log_fn = log_fn;
+
+ if (!(tdb->name = (char *)strdup(name))) {
+ errno = ENOMEM;
+ goto fail;
+ }
if ((open_flags & O_ACCMODE) == O_WRONLY) {
TDB_LOG((tdb, 0, "tdb_open_ex: can't open tdb %s write-only\n",
@@ -1497,12 +1502,6 @@ TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags,
goto fail;
}
- /* map the database and fill in the return structure */
- tdb->name = (char *)strdup(name);
- if (!tdb->name) {
- errno = ENOMEM;
- goto fail;
- }
tdb->map_size = st.st_size;
tdb->device = st.st_dev;
tdb->inode = st.st_ino;