diff options
author | Jakub Jelinek <jakub@redhat.com> | 2009-02-04 22:36:03 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2009-02-04 22:36:03 +0000 |
commit | 73c5dd45bc405428148ee740cac61a1279fe57d4 (patch) | |
tree | 878555d8c116d7ac9cb716b79e10d240fde946a3 /misc | |
parent | 23a4b43d6a98912d505458daeced44b22830a773 (diff) | |
download | glibc-73c5dd45bc405428148ee740cac61a1279fe57d4.zip glibc-73c5dd45bc405428148ee740cac61a1279fe57d4.tar.gz glibc-73c5dd45bc405428148ee740cac61a1279fe57d4.tar.bz2 |
Updated to fedora-glibc-20090204T2135cvs/fedora-glibc-2_9_90-3
Diffstat (limited to 'misc')
-rw-r--r-- | misc/Makefile | 4 | ||||
-rw-r--r-- | misc/bug-hsearch1.c | 31 | ||||
-rw-r--r-- | misc/hsearch_r.c | 6 | ||||
-rw-r--r-- | misc/sbrk.c | 10 |
4 files changed, 45 insertions, 6 deletions
diff --git a/misc/Makefile b/misc/Makefile index eb97ac1..a256068 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 1991-2006, 2007, 2009 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 @@ -79,7 +79,7 @@ endif gpl2lgpl := error.c error.h tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \ - tst-error1 tst-pselect tst-insremque tst-mntent2 + tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 ifeq (no,$(cross-compiling)) tests: $(objpfx)tst-error1-mem endif diff --git a/misc/bug-hsearch1.c b/misc/bug-hsearch1.c new file mode 100644 index 0000000..6097b5a --- /dev/null +++ b/misc/bug-hsearch1.c @@ -0,0 +1,31 @@ +#include <search.h> +#include <stdio.h> + +static int +do_test (void) +{ + if (hcreate (1) == 0) + { + puts ("hcreate failed"); + return 1; + } + ENTRY e; + e.key = (char *) "a"; + e.data = (char *) "b"; + if (hsearch (e, ENTER) == NULL) + { + puts ("ENTER failed"); + return 1; + } + ENTRY s; + s.key = (char *) "c"; + if (hsearch (s, FIND) != NULL) + { + puts ("FIND succeeded"); + return 1; + } + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c index c855a41..6e32afc 100644 --- a/misc/hsearch_r.c +++ b/misc/hsearch_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008 +/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993. @@ -79,6 +79,10 @@ hcreate_r (nel, htab) if (htab->table != NULL) return 0; + /* We need a size of at least 3. Otherwise the hash functions we + use will not work. */ + if (nel < 3) + nel = 3; /* Change nel to the first prime number not smaller as nel. */ nel |= 1; /* make odd */ while (!isprime (nel)) diff --git a/misc/sbrk.c b/misc/sbrk.c index 0df6007..985b347 100644 --- a/misc/sbrk.c +++ b/misc/sbrk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1995,1996,1997,2000,2002 Free Software Foundation, Inc. +/* Copyright (C) 1991,1995-1997,2000,2002,2009 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 @@ -16,8 +16,9 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <unistd.h> #include <errno.h> +#include <stdint.h> +#include <unistd.h> /* Defined in brk.c. */ extern void *__curbrk; @@ -47,7 +48,10 @@ __sbrk (intptr_t increment) return __curbrk; oldbrk = __curbrk; - if (__brk (oldbrk + increment) < 0) + if ((increment > 0 + ? ((uintptr_t) oldbrk + (uintptr_t) increment < (uintptr_t) oldbrk) + : ((uintptr_t) oldbrk < (uintptr_t) -increment)) + || __brk (oldbrk + increment) < 0) return (void *) -1; return oldbrk; |