wbclient: gr_mem can be NULL
authorAndrew Tridgell <tridge@samba.org>
Thu, 16 Sep 2010 10:12:20 +0000 (20:12 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 16 Sep 2010 11:09:18 +0000 (21:09 +1000)
if the structure was partly created and an error occurred, then don't
crash

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

nsswitch/libwbclient/wbc_pwd.c

index c7bfdb8fd88305e8a76f967b1838f85461d78591..1527808d888d98eb581ccdee5a8eafccb9455e75 100644 (file)
@@ -100,6 +100,11 @@ static void wbcGroupDestructor(void *ptr)
        free(gr->gr_name);
        free(gr->gr_passwd);
 
+       /* if the array was partly created this can be NULL */
+       if (gr->gr_mem == NULL) {
+               return;
+       }
+
        for (i=0; gr->gr_mem[i] != NULL; i++) {
                free(gr->gr_mem[i]);
        }