diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2007-03-12 20:30:08 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2007-03-12 20:30:08 +0000 |
commit | 99304ce6c4067c1ad11d9c4723580cb09bf1d853 (patch) | |
tree | 036546660dab37a67da4adc69fbe41610e64fdf8 /newlib/libc/stdio/fvwrite.c | |
parent | 9c28809c0f505ea1969523aad89b3a7df045bb7c (diff) | |
download | cygnal-99304ce6c4067c1ad11d9c4723580cb09bf1d853.tar.gz cygnal-99304ce6c4067c1ad11d9c4723580cb09bf1d853.tar.bz2 cygnal-99304ce6c4067c1ad11d9c4723580cb09bf1d853.zip |
2007-03-12 Eric Blake <ebb9@byu.net>
* libc/stdio/fvwrite.c (__sfvwrite_r): Fix reentrancy.
* libc/stdio/vasprintf.c (vasprintf, _vasprintf_r): Pass failed
allocation to caller.
* libc/stdio/asprintf.c (_asprintf_r, asprintf): Likewise.
* libc/stdio/asiprintf.c (_asiprintf_r, asiprintf): Likewise.
* libc/stdio/vasiprintf.c (vasiprintf, _vasiprintf_r): Likewise.
Diffstat (limited to 'newlib/libc/stdio/fvwrite.c')
-rw-r--r-- | newlib/libc/stdio/fvwrite.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c index ef461d31d..21167c7f1 100644 --- a/newlib/libc/stdio/fvwrite.c +++ b/newlib/libc/stdio/fvwrite.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1990, 2006 The Regents of the University of California. + * Copyright (c) 1990, 2006, 2007 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -129,7 +129,7 @@ _DEFUN(__sfvwrite_r, (ptr, fp, uio), { if (len >= w && fp->_flags & __SMBF) { /* must be asprintf family */ - unsigned char *ptr; + unsigned char *str; int curpos = (fp->_p - fp->_bf._base); /* Choose a geometric growth factor to avoid quadratic realloc behavior, but use a rate less @@ -141,17 +141,16 @@ _DEFUN(__sfvwrite_r, (ptr, fp, uio), int newsize = fp->_bf._size * 3 / 2; if (newsize < curpos + len + 1) newsize = curpos + len + 1; - ptr = (unsigned char *)_realloc_r (_REENT, - fp->_bf._base, - newsize); - if (!ptr) + str = (unsigned char *)_realloc_r (ptr, fp->_bf._base, + newsize); + if (!str) { /* Free buffer which is no longer used. */ - _free_r (_REENT, fp->_bf._base); + _free_r (ptr, fp->_bf._base); goto err; } - fp->_bf._base = ptr; - fp->_p = ptr + curpos; + fp->_bf._base = str; + fp->_p = str + curpos; fp->_bf._size = newsize; w = len; fp->_w = newsize - curpos; |