Fix crash in recode when the INTO variable was invalid.
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 26 Mar 2016 07:48:14 +0000 (08:48 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 26 Mar 2016 07:48:14 +0000 (08:48 +0100)
Found by zzuf.

src/language/lexer/variable-parser.c
tests/language/xforms/recode.at

index 8c4f8fe8a61acff13b83aee122c76ed2b4140e6c..a45d384293ba9b6251433a60abd4d89480dbc9fa 100644 (file)
@@ -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
index cf5036d49d6559d8cb12775ccbcade6743b7a1e0..d2290d75823c188e828ee35cb7f8e70e07919ff9 100644 (file)
@@ -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