about summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-04-24 08:55:46 +0000
committerJakub Jelinek <jakub@redhat.com>2006-04-24 08:55:46 +0000
commitd0145e03799e484f3a53d79de3b3f34162ee9d3c (patch)
treed8c51a0952204f9015de0db3319d4c820e8646e0 /libio
parentf5ce81c94cc27035f44d37bffa7f7e08dbce7631 (diff)
downloadglibc-d0145e03799e484f3a53d79de3b3f34162ee9d3c.tar.gz
glibc-d0145e03799e484f3a53d79de3b3f34162ee9d3c.tar.xz
glibc-d0145e03799e484f3a53d79de3b3f34162ee9d3c.zip
Updated to fedora-glibc-20060424T0820
Diffstat (limited to 'libio')
-rw-r--r--libio/fmemopen.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libio/fmemopen.c b/libio/fmemopen.c
index b847f62c9a..f3b280092c 100644
--- a/libio/fmemopen.c
+++ b/libio/fmemopen.c
@@ -1,5 +1,5 @@
 /* Fmemopen implementation.
-   Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2005, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by  Hanno Mueller, kontakt@hanno.de, 2000.
 
@@ -202,7 +202,7 @@ fmemopen (void *buf, size_t len, const char *mode)
   cookie_io_functions_t iof;
   fmemopen_cookie_t *c;
 
-  if (len == 0)
+  if (__builtin_expect (len == 0, 0))
     {
     einval:
       __set_errno (EINVAL);
@@ -227,8 +227,11 @@ fmemopen (void *buf, size_t len, const char *mode)
     }
   else
     {
-      if ((uintptr_t) len > -(uintptr_t) buf)
-	goto einval;
+      if (__builtin_expect ((uintptr_t) len > -(uintptr_t) buf, 0))
+	{
+	  free (c);
+	  goto einval;
+	}
 
       c->buffer = buf;
     }