DESCRIPTIVES: Fix a bug where the parser could enter an infinite loop
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 11 May 2017 14:38:11 +0000 (16:38 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 11 May 2017 16:01:52 +0000 (18:01 +0200)
src/language/stats/descriptives.c

index ce472567595f4073f2b9f56a825317664d887a2c..7182049a6668850f02ffc28c08c9f1d58cf7773e 100644 (file)
@@ -284,7 +284,15 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds)
               else if (lex_match_id (lexer, "DEFAULT"))
                 dsc->show_stats |= DEFAULT_STATS;
               else
-               dsc->show_stats |= 1ul << (match_statistic (lexer));
+               {
+                 enum dsc_statistic s = match_statistic (lexer);
+                 if (s == DSC_NONE )
+                   {
+                     lex_error (lexer, NULL);
+                     goto error;
+                   }
+                 dsc->show_stats |= 1ul << s;
+               }
               lex_match (lexer, T_COMMA);
             }
           if (dsc->show_stats == 0)