diff options
Diffstat (limited to 'newlib/libc/stdio/vdprintf.c')
-rw-r--r-- | newlib/libc/stdio/vdprintf.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/newlib/libc/stdio/vdprintf.c b/newlib/libc/stdio/vdprintf.c index 617d9db1f..8a20235ef 100644 --- a/newlib/libc/stdio/vdprintf.c +++ b/newlib/libc/stdio/vdprintf.c @@ -2,6 +2,7 @@ * Permission to use, copy, modify, and distribute this software * is freely granted, provided that this notice is preserved. */ +/* doc in dprintf.c */ #include <_ansi.h> #include <reent.h> @@ -18,14 +19,16 @@ _DEFUN(_vdprintf_r, (ptr, fd, format, ap), va_list ap) { char *p; - int n; + char buf[512]; + size_t n = sizeof buf; _REENT_SMALL_CHECK_INIT (ptr); - n = _vasprintf_r (ptr, &p, format, ap); - if (n == -1) + p = _vasnprintf_r (ptr, buf, &n, format, ap); + if (!p) return -1; n = _write_r (ptr, fd, p, n); - _free_r (ptr, p); + if (p != buf) + _free_r (ptr, p); return n; } |