diff options
Diffstat (limited to 'libio/fmemopen.c')
-rw-r--r-- | libio/fmemopen.c | 11 |
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; } |