summaryrefslogtreecommitdiff
path: root/libbb/xfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r--libbb/xfuncs.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 67c986640..4e17c28bd 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -484,12 +484,14 @@ int fdprintf(int fd, const char *format, ...)
484#else 484#else
485 // Bloat for systems that haven't got the GNU extension. 485 // Bloat for systems that haven't got the GNU extension.
486 va_start(p, format); 486 va_start(p, format);
487 r = vsnprintf(NULL, 0, format, p); 487 r = vsnprintf(NULL, 0, format, p) + 1;
488 va_end(p);
489 string_ptr = xmalloc(r+1);
490 va_start(p, format);
491 r = vsnprintf(string_ptr, r+1, format, p);
492 va_end(p); 488 va_end(p);
489 string_ptr = malloc(r);
490 if (string_ptr) {
491 va_start(p, format);
492 r = vsnprintf(string_ptr, r, format, p);
493 va_end(p);
494 }
493#endif 495#endif
494 496
495 if (r >= 0) { 497 if (r >= 0) {