Fix crash when running GET DATA with incomplete command.
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 24 Mar 2016 20:07:04 +0000 (21:07 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 24 Mar 2016 21:24:26 +0000 (22:24 +0100)
Found by zzuf.

src/language/data-io/get-data.c
tests/language/data-io/get-data-txt.at

index f2c294264ce951c5e66597d5a66cd0cfd55f8e69..9d1e28100e32f5beb8e2a52401c80deacd7b1aba 100644 (file)
@@ -93,9 +93,14 @@ cmd_get_data (struct lexer *lexer, struct dataset *ds)
   if (!lex_force_match_id (lexer, "TYPE"))
     goto error;
 
-  lex_force_match (lexer, T_EQUALS);
+  if (!lex_force_match (lexer, T_EQUALS))
+    goto error;
 
-  tok = strdup (lex_tokcstr (lexer));
+  const char *s = lex_tokcstr (lexer);
+
+  if (s)
+    tok = strdup (s);
+  
   if (lex_match_id (lexer, "TXT"))
     {
       free (tok);
index 9e01aae3744f921ac26b304e78b8bd62a6b6bfc9..b0b2616f7ae44cbc02740f0b383f6c957e1cc3b2 100644 (file)
@@ -329,3 +329,17 @@ s
 é      @&t@
 ])
 AT_CLEANUP
+
+
+AT_SETUP([GET DATA /TYPE= truncated])
+
+AT_DATA([x.sps], [dnl
+GET DATA /TYPE=
+.
+])
+
+AT_CHECK([pspp -o pspp.csv x.sps], [1], [ignore])
+
+AT_CLEANUP
+
+