Fixed crash in MODIFY OUTPUT when no valid FORMAT clause was specified.
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 26 Mar 2016 15:13:50 +0000 (16:13 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 26 Mar 2016 15:14:32 +0000 (16:14 +0100)
Found by zzuf.

src/language/utilities/output.c
tests/output/tables.at

index ac60663909866e18d3898e5c405f90087e2f0d77..fc390992b96b494de1bf81b7367b43e99f4f6dba 100644 (file)
@@ -93,6 +93,7 @@ cmd_output (struct lexer *lexer, struct dataset *ds UNUSED)
          os = &output_specs[n_os - 1];
          os->n_rc = 0;
          os->rc = NULL;
+         bool format = false;
          
          while (lex_token (lexer) != T_SLASH && 
                 lex_token (lexer) != T_ENDCMD)
@@ -153,20 +154,21 @@ cmd_output (struct lexer *lexer, struct dataset *ds UNUSED)
                  fmt.d = decimals;
 
                  os->fmt = fmt;
+                 format = true;
                }
              else 
                {
                  lex_error (lexer, NULL);
                  goto error;
-           
                }
            }
+         if (!format)
+           goto error;
        }
       else 
        {
          lex_error (lexer, NULL);
          goto error;   
-
        }
     }
 
index 10b321a4e246788d4a72591e73c7c8159334e3e5..1a7727fc2e515f331fd0bcc15f05fc100e55aafe 100644 (file)
@@ -1,6 +1,6 @@
 AT_BANNER([output -- tables])
 
-AT_SETUP([precision])
+AT_SETUP([OUTPUT precision])
 
 AT_DATA([prec.sps], [[
 data list notable list /A * B *.
@@ -61,3 +61,27 @@ Pair 1,A - B,-2.00,.94,.42,-3.16,-.84,-4.78,4,.00877
 ])
 
 AT_CLEANUP
+
+
+
+
+AT_SETUP([OUTPUT crash])
+
+AT_DATA([prec.sps], [[
+data list notable list /A * B *.
+begin data.
+2.0 3.0
+1.0 2.0
+end data.
+
+OUTPUT MODIFY 
+       /SELECT TABLES 
+       /TABLECELLS  SELECT = [ SIGNIFICANCE ] 
+       "FORMAT = F/1.
+
+t-test /PAIRS a with b (PAIRED).
+]])
+
+AT_CHECK([pspp -O format=csv prec.sps], [1], [ignore])
+
+AT_CLEANUP
\ No newline at end of file