diff options
author | Ron Yorston <rmy@pobox.com> | 2016-07-08 08:50:16 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-07-08 08:50:16 +0100 |
commit | 3ee1cc4e3986b74a7126871ad2a677b9e3ac3662 (patch) | |
tree | 36b7976e0b43f0cd3963095286fb444520a4827d | |
parent | 613f46218c53c8cabdbf0435653e74e0e0e91e1c (diff) | |
download | busybox-w32-3ee1cc4e3986b74a7126871ad2a677b9e3ac3662.tar.gz busybox-w32-3ee1cc4e3986b74a7126871ad2a677b9e3ac3662.tar.bz2 busybox-w32-3ee1cc4e3986b74a7126871ad2a677b9e3ac3662.zip |
win32: allow for vsnprintf returning -1
vsnprintf can return -1. I've seen it do this when writing to a small
buffer while vsnprintf(NULL, 0, ...) returns a valid length. I'd prefer
not to rely on the latter working with arbitrary old Windows runtimes
so just skip ANSI emulation if -1 is returned.
-rw-r--r-- | win32/winansi.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/win32/winansi.c b/win32/winansi.c index d61e8a2cf..c0493c77e 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -536,9 +536,14 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list) | |||
536 | if (!buf) | 536 | if (!buf) |
537 | goto abort; | 537 | goto abort; |
538 | 538 | ||
539 | len = vsnprintf(buf, len + 1, format, list); | 539 | va_copy(cp, list); |
540 | len = vsnprintf(buf, len + 1, format, cp); | ||
541 | va_end(cp); | ||
540 | } | 542 | } |
541 | 543 | ||
544 | if (len == -1) | ||
545 | goto abort; | ||
546 | |||
542 | rv = ansi_emulate(buf, stream); | 547 | rv = ansi_emulate(buf, stream); |
543 | 548 | ||
544 | if (buf != small_buf) | 549 | if (buf != small_buf) |