r19080: Fix a potential NULL dereference
authorVolker Lendecke <vlendec@samba.org>
Wed, 4 Oct 2006 21:07:05 +0000 (21:07 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:15:09 +0000 (12:15 -0500)
source/lib/util.c

index e04ed977bb978095710d633bf1259b233bbf95eb..19c6cab5b28a5550f2889d9b4f3b99a1980bcc92 100644 (file)
@@ -312,6 +312,13 @@ void add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid,
 {
        int i;
 
+       if ((*num_gids != 0) && (*gids == NULL)) {
+               /*
+                * A former call to this routine has failed to allocate memory
+                */
+               return;
+       }
+
        for (i=0; i<*num_gids; i++) {
                if ((*gids)[i] == gid)
                        return;