From 4bfbca70ea14a336bcfcfb31260072cc5abd1661 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Fri, 29 Mar 2024 13:28:06 -0700 Subject: [PATCH] Try dynamically heap allocating 'ex' instead of a stack-allocated VLA to avoid ASan stack-overflow --- src/topmodel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/topmodel.c b/src/topmodel.c index cc9f4e6..a14291e 100755 --- a/src/topmodel.c +++ b/src/topmodel.c @@ -143,13 +143,13 @@ extern void topmod(FILE *output_fptr, int nstep, int num_topodex_values, current_time_step, *sump, *sumae, *sumq, stand_alone added as function input parameters */ -double ex[num_topodex_values+1]; //+1 to maintin 1 based array indexing //NJF TODO consider warning on all program limits here since this is essentially //"the model" where those assumptions may not be valid... if(num_topodex_values > WARN_TOPODEX_INCREMENTS){ printf("WARNING: num_topodex_values, %d, is greater than %d\n", num_topodex_values, WARN_TOPODEX_INCREMENTS); } +double *ex = malloc(sizeof(double)*(num_topodex_values+1)); //+1 to maintin 1 based array indexing int ia,ib,in,irof,it,ir; double rex,cumf,max_contrib_area,ea,rint,acm,df; double acf,uz,sae,of; @@ -364,6 +364,8 @@ for(ia=1;ia<=num_topodex_values;ia++) } +free(ex); + return; }