about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2010-06-19 11:38:04 -0700
committerUlrich Drepper <drepper@redhat.com>2010-06-19 11:38:04 -0700
commitac2b484c02b01307ab6bbe5d45ddbf16d64edf8c (patch)
treed937bc5e083c7eddc92e3d26e496d2082627f027 /posix
parent63c4ed22b5048c8701d8806026c23cc95f0df756 (diff)
downloadglibc-ac2b484c02b01307ab6bbe5d45ddbf16d64edf8c.tar.gz
glibc-ac2b484c02b01307ab6bbe5d45ddbf16d64edf8c.tar.xz
glibc-ac2b484c02b01307ab6bbe5d45ddbf16d64edf8c.zip
Correct checking loop in group_member.
Diffstat (limited to 'posix')
-rw-r--r--posix/group_member.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/posix/group_member.c b/posix/group_member.c
index 7bd9c46ba2..892755e95a 100644
--- a/posix/group_member.c
+++ b/posix/group_member.c
@@ -1,5 +1,5 @@
 /* `group_member' -- test if process is in a given group.
-   Copyright (C) 1995, 1997, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1997, 2002, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -39,10 +39,11 @@ __group_member (gid)
       groups = __alloca (size * sizeof *groups);
       n = __getgroups (size, groups);
       size *= 2;
-    } while (n == size / 2);
+    }
+  while (n == size / 2);
 
-  while (n >= 0)
-    if (groups[n--] == gid)
+  while (n-- > 0)
+    if (groups[n] == gid)
       return 1;
 
   return 0;