r20090: Fix a class of bugs found by James Peach. Ensure
[samba.git] / source / smbd / service.c
index c2dd062777b7d1b2e64869a00f2f05b19015f088..62d85cfdd97795f375db83691533cd26b5c03f64 100644 (file)
@@ -853,8 +853,13 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
                                           sid_string_static(sid)));
                                continue;
                        }
-                       add_gid_to_array_unique(NULL, gid, &conn->groups,
-                                               &conn->ngroups);
+                       if (!add_gid_to_array_unique(NULL, gid, &conn->groups,
+                                               &conn->ngroups)) {
+                               DEBUG(0, ("add_gid_to_array_unique failed\n"));
+                               conn_free(conn);
+                               *status = NT_STATUS_NO_MEMORY;
+                               return NULL;
+                       }
                }
        }