From 35c543f1ab34629913ee5799bcdf4bb2993b3649 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 26 Mar 2016 08:48:14 +0100 Subject: [PATCH] Fix crash in recode when the INTO variable was invalid. Found by zzuf. --- src/language/lexer/variable-parser.c | 7 +++++-- tests/language/xforms/recode.at | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/language/lexer/variable-parser.c b/src/language/lexer/variable-parser.c index 8c4f8fe8a6..a45d384293 100644 --- a/src/language/lexer/variable-parser.c +++ b/src/language/lexer/variable-parser.c @@ -633,7 +633,10 @@ parse_mixed_vars (struct lexer *lexer, const struct dictionary *dict, else if (!parse_DATA_LIST_vars (lexer, dict, names, nnames, PV_APPEND)) goto fail; } - return 1; + if (*nnames == 0) + goto fail; + + return true; fail: for (i = 0; i < *nnames; i++) @@ -641,7 +644,7 @@ fail: free (*names); *names = NULL; *nnames = 0; - return 0; + return false; } /* Parses a list of variables where some of the variables may be diff --git a/tests/language/xforms/recode.at b/tests/language/xforms/recode.at index cf5036d49d..d2290d7582 100644 --- a/tests/language/xforms/recode.at +++ b/tests/language/xforms/recode.at @@ -325,3 +325,25 @@ c,b ,2.00 ]) AT_CLEANUP + + + +AT_SETUP([RECODE crash on invalid dest variable]) + +AT_DATA([recode.sps],[dnl +DATA LIST LIST NOTABLE/x (f1) s (a4) t (a10). +MISSING VALUES x(9)/s('xxx'). +BEGIN DATA. +0, '', '' +1, a, a +2, ab, ab +3, abc, abc +END DATA. + +RECODE x (1=9) INTO ". +EXECUTE. +]) + +AT_CHECK([pspp -O format=csv recode.sps], [1], [ignore]) + +AT_CLEANUP -- 2.30.2