From 1ee2c545b0c04eb94c19c8aa9d98ddf093f1860a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 20 Jul 2019 21:34:41 -0700 Subject: [PATCH] shapiro-wilk: Fix memory leak. CC: John Darrington Fixes: 0b7e8882ce9b ("EXAMINE: Implement the Shapiro-Wilk Test.") --- src/math/shapiro-wilk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/math/shapiro-wilk.c b/src/math/shapiro-wilk.c index f48156e97c..30feb39d9d 100644 --- a/src/math/shapiro-wilk.c +++ b/src/math/shapiro-wilk.c @@ -116,6 +116,9 @@ shapiro_wilk_calculate (const struct shapiro_wilk *sw) struct shapiro_wilk * shapiro_wilk_create (int n, double mean) { + if (n < 3 || n > 5000) + return NULL; + struct shapiro_wilk *sw = xzalloc (sizeof (*sw)); struct order_stats *os = &sw->parent; struct statistic *stat = &os->parent; @@ -128,9 +131,6 @@ shapiro_wilk_create (int n, double mean) sw->n = n; - if (n < 3 || n > 5000) - return NULL; - const double u = 1.0 / sqrt (sw->n); double m = 0; -- 2.30.2