Fixed bug in NPAR BINOMIAL 20121124030501/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 24 Nov 2012 08:06:54 +0000 (09:06 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 24 Nov 2012 08:06:54 +0000 (09:06 +0100)
This bug would crash when an incorrect syntax was encountered.

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

index af41b104731665e4adb4202d609de00fa8f77a7d..737c94e3d2a296dfd4f999dac4e822c5c08e5ea3 100644 (file)
@@ -945,7 +945,8 @@ npar_binomial (struct lexer *lexer, struct dataset *ds,
        {
          if (lex_match (lexer, T_LPAREN))
            {
-             lex_force_num (lexer);
+             if (! lex_force_num (lexer))
+               return 2;
              btp->category1 = lex_number (lexer);
              lex_get (lexer);
              if ( lex_match (lexer, T_COMMA))
index 38e2e7c4c1520e164855fcd22f8ba9be94a34729..f5eb2a404cc803182e338251244afc2eabf67624 100644 (file)
@@ -274,6 +274,28 @@ x,Group1,10.000,10.000,.435,.500,.678
 ])
 AT_CLEANUP
 
+
+
+dnl Test for a bug which caused binomial to crash.
+AT_SETUP([NPAR TESTS BINOMIAL - crash])
+AT_DATA([nparX.sps], [dnl
+data list list /range *.
+begin data.
+0
+1
+end data.
+
+* This is invalid syntax
+NPAR TEST
+       /BINOMIAL(0.5) = Range().
+
+])
+AT_CHECK([pspp -O format=csv nparX.sps], [1], [ignore])
+
+AT_CLEANUP
+
+
+
 AT_SETUP([NPAR TESTS CHISQUARE])
 AT_DATA([npar.sps], [dnl
 DATA LIST NOTABLE LIST /x * y * w *.