From: John Darrington Date: Thu, 24 Mar 2016 20:07:04 +0000 (+0100) Subject: Fix crash when running GET DATA with incomplete command. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3de625dbfb973ef841341b14a0db7e0b2abec83f;p=pspp Fix crash when running GET DATA with incomplete command. Found by zzuf. --- diff --git a/src/language/data-io/get-data.c b/src/language/data-io/get-data.c index f2c294264c..9d1e28100e 100644 --- a/src/language/data-io/get-data.c +++ b/src/language/data-io/get-data.c @@ -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); diff --git a/tests/language/data-io/get-data-txt.at b/tests/language/data-io/get-data-txt.at index 9e01aae374..b0b2616f7a 100644 --- a/tests/language/data-io/get-data-txt.at +++ b/tests/language/data-io/get-data-txt.at @@ -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 + +