]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/tdb: clang: Fix warning: Dereference of null pointer
authorNoel Power <noel.power@suse.com>
Wed, 12 Jun 2019 14:55:43 +0000 (14:55 +0000)
committerNoel Power <npower@samba.org>
Wed, 26 Jun 2019 10:30:23 +0000 (10:30 +0000)
Fixes:

lib/tdb/common/lock.c:933:6: warning: Dereference of null pointer <--[clang]
        if (tdb->allrecord_lock.count) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/tdb/common/lock.c

index f55184d8be5ca368a4512913d773a69e545f0a48..5fba02f9b12dd879e5e1904bd09808a3b9b2f476 100644 (file)
@@ -927,6 +927,9 @@ int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off)
 int tdb_write_lock_record(struct tdb_context *tdb, tdb_off_t off)
 {
        struct tdb_traverse_lock *i;
+       if (tdb == NULL) {
+               return -1;
+       }
        for (i = &tdb->travlocks; i; i = i->next)
                if (i->off == off)
                        return -1;