Fix bug 22419
[pspp-builds.git] / src / math / linreg / linreg.c
index 4fc3b20a74d55bb5d284e5269764edf861312eed..9465875e81b3c697d58fa27112bccc466188ece3 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2005 Free Software Foundation, Inc. Written by Jason H. Stover.
+   Copyright (C) 2005 Free Software Foundation, Inc. 
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -94,9 +94,9 @@ int
 pspp_linreg_get_vars (const void *c_, const struct variable **v)
 {
   const pspp_linreg_cache *c = c_;
-  struct pspp_coeff *coef = NULL;
   const struct variable *tmp;
   int i;
+  int j;
   int result = 0;
 
   /*
@@ -110,12 +110,9 @@ pspp_linreg_get_vars (const void *c_, const struct variable **v)
   /*
      Start at c->coeff[1] to avoid the intercept.
    */
-  v[result] = pspp_coeff_get_var (c->coeff[1], 0);
-  result = (v[result] == NULL) ? 0 : 1;
-
-  for (coef = c->coeff[2]; coef < c->coeff[c->n_coeffs]; coef++)
+  for (j = 1; j < c->n_coeffs; j++)
     {
-      tmp = pspp_coeff_get_var (coef, 0);
+      tmp = pspp_coeff_get_var (c->coeff[j], 0);
       assert (tmp != NULL);
       /* Repeated variables are likely to bunch together, at the end
          of the array. */