wbclient: paranoid check for double free
authorAndrew Tridgell <tridge@samba.org>
Thu, 16 Sep 2010 10:11:47 +0000 (20:11 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 16 Sep 2010 11:09:17 +0000 (21:09 +1000)
added while tracking down a crash in the wbinfo blackbox test

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

nsswitch/libwbclient/wbclient.c

index 15be255d45de33df57579ade614fd907d0b0c79f..19bb3e9e0a85348adabbd0fe19c6a397c2eec2a1 100644 (file)
@@ -148,6 +148,7 @@ const char *wbcErrorString(wbcErr error)
 }
 
 #define WBC_MAGIC (0x7a2b0e1e)
+#define WBC_MAGIC_FREE (0x875634fe)
 
 struct wbcMemPrefix {
        uint32_t magic;
@@ -197,6 +198,10 @@ void wbcFreeMemory(void *p)
        if (wbcMem->magic != WBC_MAGIC) {
                return;
        }
+
+       /* paranoid check to ensure we don't double free */
+       wbcMem->magic = WBC_MAGIC_FREE;
+
        if (wbcMem->destructor != NULL) {
                wbcMem->destructor(p);
        }