Fix crash in NPAR when no variables were parsed.
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 31 Mar 2016 20:27:52 +0000 (22:27 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 31 Mar 2016 20:27:52 +0000 (22:27 +0200)
Found by zzuf.

src/language/stats/npar.c
tests/language/stats/npar.at

index b8cbb1bcf20bbec2e885c341a1a01738d7aececf..92b86252e4f50ba4dddc5dc7b5ab5c03490225b6 100644 (file)
@@ -539,7 +539,7 @@ npar_execute (struct casereader *input,
       test->execute (ds, casereader_clone (input), specs->filter, test, specs->exact, specs->timer);
     }
 
-  if ( specs->descriptives )
+  if (specs->descriptives && specs->n_vars > 0)
     {
       summary_descriptives = xnmalloc (sizeof (*summary_descriptives),
                                       specs->n_vars);
index ed829cdc524a68f37ceb742f9e1a085ac65e1f2c..038b788df130a203a9b2a030baeab2c187635f91 100644 (file)
@@ -1764,4 +1764,28 @@ npar tests
 AT_CHECK([pspp -O format=csv npar.sps], [1], [ignore])
 
 AT_CLEANUP
+
+
+
+
+AT_SETUP([NPAR TESTS - crash on unterminated string])
+
+AT_DATA([npar.sps], [dnl
+DATA LIST NOTABLE LIST /x * y * w * .
+BEGIN DATA.
+3.1 1  4
+3.2 2  1
+4   2  6
+END DATA.
+
+
+NPAR TESTS
+" CHISQUARE=x y(-2,5)
+  /STATISTICS=DESCRIPTIVES
+  .
+])
+
+AT_CHECK([pspp -O format=csv npar.sps], [1], [ignore])
+
+AT_CLEANUP
  
\ No newline at end of file