Reliability: Fix crash on invalid syntax 20130126030502/pspp 20130127030503/pspp 20130128030503/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 25 Jan 2013 11:34:31 +0000 (12:34 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 25 Jan 2013 11:34:31 +0000 (12:34 +0100)
src/language/stats/reliability.c
tests/language/stats/reliability.at

index 144c31125b6f7fc4ca70c22b92bb79a7abfba284..a9e33fb20a9095e9c56a69b66fabace4866846c3 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011, 2013 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
@@ -113,15 +113,16 @@ reliability_destroy (struct reliability *rel)
 {
   int j;
   ds_destroy (&rel->scale_name);
-  for (j = 0; j < rel->n_sc ; ++j)
-    {
-      int x;
-      free (rel->sc[j].items);
-      moments1_destroy (rel->sc[j].total);
-      for (x = 0; x < rel->sc[j].n_items; ++x)
-       free (rel->sc[j].m[x]);
-      free (rel->sc[j].m);
-    }
+  if (rel->sc)
+    for (j = 0; j < rel->n_sc ; ++j)
+      {
+       int x;
+       free (rel->sc[j].items);
+       moments1_destroy (rel->sc[j].total);
+       for (x = 0; x < rel->sc[j].n_items; ++x)
+         free (rel->sc[j].m[x]);
+       free (rel->sc[j].m);
+      }
 
   free (rel->sc);
   free (rel->variables);
@@ -136,11 +137,11 @@ cmd_reliability (struct lexer *lexer, struct dataset *ds)
   reliability.n_variables = 0;
   reliability.variables = NULL;
   reliability.model = MODEL_ALPHA;
-    reliability.exclude = MV_ANY;
+  reliability.exclude = MV_ANY;
   reliability.summary = 0;
-
+  reliability.n_sc = 0;
+  reliability.sc = NULL;
   reliability.wv = dict_get_weight (dict);
-
   reliability.total_start = 0;
 
   lex_match (lexer, T_SLASH);
index 5676b9469039b1d0c8ccbad5cf62140a6a90202e..f320d3e6f38246772e474e4e43c3173b541f2d8d 100644 (file)
@@ -247,3 +247,24 @@ Cronbach's Alpha,N of Items
 .75,4
 ])
 AT_CLEANUP
+
+
+dnl This was causing a AT.  
+AT_SETUP([RELIABILITY bad syntax])
+AT_DATA([bad-syntax.sps], [dnl
+data list notable list /x * y *.
+begin data.
+1 10
+2 20
+3 30
+4 50
+5 50
+end data.
+
+* This syntax is incorrect
+reliability x y.
+])
+
+AT_CHECK([pspp -O format=csv bad-syntax.sps], [1], [ignore])
+
+AT_CLEANUP