From bc280f82e8d7b6c1016f2198dfd89834db4d0355 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Tue, 11 Oct 2016 18:00:31 -0700 Subject: [PATCH] Avoid the use of variable length arrays. Microsoft has not implemented and refuses to implement C99 aspects that are not also part of C++11 or later C++ standards. (Note that the "99" in C99 refers to 1999. That was the year my younger son was born, who is now applying for college.) --- pigz.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pigz.c b/pigz.c index a663c92..6ad6aa0 100644 --- a/pigz.c +++ b/pigz.c @@ -1003,8 +1003,9 @@ local unsigned put(int out, ...) { } va_end(ap); - /* allocate memory on the stack for the data */ - unsigned char wrap[count], *next = wrap; + /* allocate memory for the data */ + unsigned char *wrap = alloc(NULL, count); + unsigned char *next = wrap; /* write the requested data to wrap[] */ va_start(ap, out); @@ -1017,17 +1018,18 @@ local unsigned put(int out, ...) { *next++ = val >> n; } while (n); } - else { /* little endian */ + else /* little endian */ do { *next++ = val; val >>= 8; } while (--n); - } } va_end(ap); /* write wrap[] to out and return the number of bytes written */ - return writen(out, wrap, count); + writen(out, wrap, count); + free(wrap); + return count; } /* Low 32-bits set to all ones. */