From ac6620bbda230cf4e796fdab7ee377221651ea95 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Wed, 17 Jul 2024 00:16:56 +0000 Subject: [PATCH] Last one in fwrite --- src/fwrite.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fwrite.c b/src/fwrite.c index dacfc7e11..cd9ef98ee 100644 --- a/src/fwrite.c +++ b/src/fwrite.c @@ -848,7 +848,9 @@ void fwriteMain(fwriteMainArgs args) int failed_write = 0; // same. could use +ve and -ve in the same code but separate it out to trace Solaris problem, #3931 #ifndef NOZLIB - z_stream thread_streams[nth]; + z_stream *thread_streams = (z_stream *)malloc(nth * sizeof(z_stream)); + if (!thread_streams) + STOP(_("Failed to allocated %d bytes for '%s'."), (int)(nth * sizeof(z_stream)), "thread_streams"); // VLA on stack should be fine for nth structs; in zlib v1.2.11 sizeof(struct)==112 on 64bit // not declared inside the parallel region because solaris appears to move the struct in // memory when the #pragma omp for is entered, which causes zlib's internal self reference @@ -988,6 +990,7 @@ void fwriteMain(fwriteMainArgs args) } free(buffPool); #ifndef NOZLIB + free(thread_streams); free(zbuffPool); #endif