From 152a9bc779acb04dd4708d718accb63e95b20c44 Mon Sep 17 00:00:00 2001
From: Mathieu Westphal <mathieu.westphal@kitware.com>
Date: Tue, 18 Feb 2025 15:02:40 +0100
Subject: [PATCH] stream_cdf_i: Fix an incorrect dynamic stack alloc

---
 src/stream_cdf_i.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/stream_cdf_i.c b/src/stream_cdf_i.c
index 7cbecd140..b599c5f49 100644
--- a/src/stream_cdf_i.c
+++ b/src/stream_cdf_i.c
@@ -1155,7 +1155,7 @@ set_vars_chunks(int ncid, int ncvarid, int nvdims, ncvar_t *ncvar)
   ncvar->hasFilter = cdf_get_var_filter(ncid, ncvarid, ncvar->filterSpec, CDI_MAX_NAME);
   // if (ncvar->hasFilter) printf("filterSpec: %s=%s\n", ncvar->name, ncvar->filterSpec);
 
-  size_t chunks[nvdims];
+  size_t* chunks = malloc(sizeof(size_t) * nvdims);
   int storageIn;
   if (nc_inq_var_chunking(ncid, ncvarid, &storageIn, chunks) == NC_NOERR)
     {
@@ -1171,6 +1171,7 @@ set_vars_chunks(int ncid, int ncvarid, int nvdims, ncvar_t *ncvar)
             }
         }
     }
+  free (chunks);
 
   size_t size;
   size_t nelems;
-- 
GitLab