about summary refs log tree commit diff
path: root/grp/initgroups.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-04-21 16:15:11 +0000
committerUlrich Drepper <drepper@redhat.com>2000-04-21 16:15:11 +0000
commita711dd4ba8f2c71a260a3f7539c0e86175f97a21 (patch)
tree1bf9e3eb9a49f3b9cdcd0dee9515339486170f74 /grp/initgroups.c
parent761df3a7aa6eb65aa66c78e6c1da627e453de458 (diff)
downloadglibc-a711dd4ba8f2c71a260a3f7539c0e86175f97a21.tar.gz
glibc-a711dd4ba8f2c71a260a3f7539c0e86175f97a21.tar.xz
glibc-a711dd4ba8f2c71a260a3f7539c0e86175f97a21.zip
Update.
2000-04-21  Ulrich Drepper  <drepper@redhat.com>

	* iconv/iconv.c (iconv): Add __builtin_expect where useful.
	* iconv/iconv_close.c (iconv_close): Likewise.
	* iconv/iconv_open.c (iconv_open): Likewise.

	* grp/putgrent.c (putgrent): Unlock steam if fprintf failed.  Add
	__builtin_expect where useful.

	* grp/initgroups.c (initgroups): Test for result of memory
	allocation and punt if it fails.

	* dirent/scandir.c (scandir): Add __builtin_expect where useful.
	* grp/fgetgrent.c (fgetfrent): Likewise.
	* grp/fgetgrent_r.c (__fgetgrent_r): Likewise.
Diffstat (limited to 'grp/initgroups.c')
-rw-r--r--grp/initgroups.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/grp/initgroups.c b/grp/initgroups.c
index fd30ebf7e0..06c48bb040 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989, 91, 93, 96, 97, 98, 99 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 91, 93, 1996-1999, 2000 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
@@ -163,7 +163,10 @@ initgroups (user, group)
     size = 16;
 #endif
 
-  groups = malloc (size * sizeof (gid_t *));
+  groups = (gid_t *) malloc (size * sizeof (gid_t));
+  if (__builtin_expect (groups == NULL, 0))
+    /* No more memory.  */
+    return -1;
 
   groups[0] = group;