FREQUENCIES: Fix memory leak with percentiles and split file.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 6 Aug 2022 17:11:59 +0000 (10:11 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 6 Aug 2022 17:11:59 +0000 (10:11 -0700)
src/language/stats/frequencies.c

index a851c2196073a4ba1d3b530f70c686aca323e19f..3f7afaa361801e468879dd5e246ce4a6d6bb9c80 100644 (file)
@@ -359,7 +359,8 @@ calc_percentiles (const struct frq_proc *frq, struct var_freqs *vf)
   if (!frq->n_percentiles)
     return;
 
   if (!frq->n_percentiles)
     return;
 
-  vf->percentiles = xnmalloc (frq->n_percentiles, sizeof *vf->percentiles);
+  if (!vf->percentiles)
+    vf->percentiles = xnmalloc (frq->n_percentiles, sizeof *vf->percentiles);
 
   const struct freq_tab *ft = &vf->tab;
   const double W = ft->valid_cases;
 
   const struct freq_tab *ft = &vf->tab;
   const double W = ft->valid_cases;