From 1f041edc40cecc2918660a2ca342e3b98a7c8823 Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 26 Oct 2021 16:10:26 -0400 Subject: [PATCH] [plot] kill last VLA #2172 --- src/lib/plot.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/plot.c b/src/lib/plot.c index 86f4cd6e2..491e6146a 100644 --- a/src/lib/plot.c +++ b/src/lib/plot.c @@ -154,9 +154,13 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \ return -1; \ } \ memset(pixels, 0, dimy * dimx * states * scale * sizeof(*pixels)); \ - int idx = ncp->plot.slotstart; /* idx holds the real slot index; we move backwards */ \ /* a column corresponds to |scale| slots' worth of samples. prepare the working gval set. */ \ - T gvals[scale]; \ + T* gvals = malloc(sizeof(*gvals) * scale); \ + if(gvals == NULL){ \ + free(pixels); \ + return -1; \ + } \ + int idx = ncp->plot.slotstart; /* idx holds the real slot index; we move backwards */ \ /* iterate backwards across the plot from the final (rightmost) x being \ plotted (finalx) to the first (leftmost) x being plotted (startx). */ \ for(int x = finalx ; x >= startx ; --x){ \ @@ -230,6 +234,7 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \ ncplane_home(ncp->plot.ncp); \ struct ncvisual* ncv = ncvisual_from_rgba(pixels, dimy * states, dimx * scale * 4, dimx * scale); \ free(pixels); \ + free(gvals); \ if(ncv == NULL){ \ return -1; \ } \