shapiro-wilk: Fix memory leak.
[pspp] / src / math / shapiro-wilk.c
index f48156e97cfdd5605e36f98e9b00ebaa90971b7c..30feb39d9ddfb94cb9f844ae5f78444657a54126 100644 (file)
@@ -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;