tdb: NULL out tdb->mutexes in tdb_mutex_munmap
authorVolker Lendecke <vl@samba.org>
Mon, 21 Nov 2016 19:56:55 +0000 (20:56 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 29 Nov 2016 19:03:25 +0000 (20:03 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12455

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tdb/common/mutex.c

index 280dec1f6b8f0d8671b15e78c75a2ba0067cffd2..3420d21f348a3eaf8b2ff370f8da3480361b0bcd 100644 (file)
@@ -636,13 +636,20 @@ int tdb_mutex_mmap(struct tdb_context *tdb)
 int tdb_mutex_munmap(struct tdb_context *tdb)
 {
        size_t len;
+       int ret;
 
        len = tdb_mutex_size(tdb);
        if (len == 0) {
                return 0;
        }
 
-       return munmap(tdb->mutexes, len);
+       ret = munmap(tdb->mutexes, len);
+       if (ret == -1) {
+               return -1;
+       }
+       tdb->mutexes = NULL;
+
+       return 0;
 }
 
 static bool tdb_mutex_locking_cached;