diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-02-22 15:38:14 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-02-22 15:38:14 +0000 |
commit | d9db1bc55561a62967494227d84247618d434817 (patch) | |
tree | 10dd53d21912489f14efe14cbf52dd183a53c5ba /newlib/libc/stdio/fmemopen.c | |
parent | 12374d7d2f77d5a309f1835b3177798c47307807 (diff) | |
download | newlib-d9db1bc55561a62967494227d84247618d434817.zip newlib-d9db1bc55561a62967494227d84247618d434817.tar.gz newlib-d9db1bc55561a62967494227d84247618d434817.tar.bz2 |
* libc/stdio/fmemopen.c (fmemopen): Fix EINVAL condition. Avoid SEGV
if incoming buffer is NULL.
Diffstat (limited to 'newlib/libc/stdio/fmemopen.c')
-rw-r--r-- | newlib/libc/stdio/fmemopen.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/newlib/libc/stdio/fmemopen.c b/newlib/libc/stdio/fmemopen.c index 4458d21..5218e8a 100644 --- a/newlib/libc/stdio/fmemopen.c +++ b/newlib/libc/stdio/fmemopen.c @@ -281,7 +281,7 @@ _DEFUN(_fmemopen_r, (ptr, buf, size, mode), if ((flags = __sflags (ptr, mode, &dummy)) == 0) return NULL; - if (!size || !(buf || flags & __SAPP)) + if (!size || !(buf || flags & __SRW)) { ptr->_errno = EINVAL; return NULL; @@ -310,7 +310,7 @@ _DEFUN(_fmemopen_r, (ptr, buf, size, mode), { /* r+/w+/a+, and no buf: file starts empty. */ c->buf = (char *) (c + 1); - *(char *) buf = '\0'; + c->buf[0] = '\0'; c->pos = c->eof = 0; c->append = (flags & __SAPP) != 0; } |