leases_db: don't leak lock_path onto talloc tos
authorDavid Disseldorp <ddiss@samba.org>
Mon, 12 Jan 2015 15:49:54 +0000 (16:49 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 12 Jan 2015 18:22:30 +0000 (19:22 +0100)
Also check for allocation failures.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Jan 12 19:22:31 CET 2015 on sn-devel-104

source3/locking/leases_db.c

index 2ee6a2643bf985f3bb0d8b6ec4f55fa78e043a71..4167ef713e1002e56cdc9010389e8eaab53189e0 100644 (file)
@@ -35,16 +35,23 @@ static struct db_context *leases_db;
 
 bool leases_db_init(bool read_only)
 {
+       char *db_path;
+
        if (leases_db) {
                return true;
        }
 
-       leases_db = db_open(NULL, lock_path("leases.tdb"), 0,
+       db_path = lock_path("leases.tdb");
+       if (db_path == NULL) {
+               return false;
+       }
+
+       leases_db = db_open(NULL, db_path, 0,
                            TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST|
                            TDB_INCOMPATIBLE_HASH,
                            read_only ? O_RDONLY : O_RDWR|O_CREAT, 0644,
                            DBWRAP_LOCK_ORDER_2, DBWRAP_FLAG_NONE);
-
+       TALLOC_FREE(db_path);
        if (leases_db == NULL) {
                DEBUG(1, ("ERROR: Failed to initialise leases database\n"));
                return false;