From: Ben Pfaff Date: Sun, 21 Jul 2019 04:34:41 +0000 (-0700) Subject: shapiro-wilk: Fix memory leak. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ee2c545b0c04eb94c19c8aa9d98ddf093f1860a;p=pspp shapiro-wilk: Fix memory leak. CC: John Darrington Fixes: 0b7e8882ce9b ("EXAMINE: Implement the Shapiro-Wilk Test.") --- 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;