# HG changeset patch # User Rik # Date 1432068561 25200 # Node ID 3c8260fd0837f1f2fd790ce04dc7c01fe68df689 # Parent 70e8801a56f7db64ade8172570a4b1f12bccf8d4 Validate second option to exist () (bug #42618). * variables.cc (symbol_exist): Emit an error if the type argument is not one of the accepted values. * variables.cc (Fexist): Add BIST test to check input validation. diff -r 70e8801a56f7 -r 3c8260fd0837 libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Mon May 18 22:10:51 2015 -0700 +++ b/libinterp/corefcn/variables.cc Tue May 19 13:49:21 2015 -0700 @@ -395,6 +395,14 @@ bool search_dir = type == "dir"; bool search_file = type == "file"; bool search_builtin = type == "builtin"; + bool search_class = type == "class"; + + if (! (search_any || search_var || search_dir || search_file || + search_builtin || search_class)) + { + error ("exist: unrecognized type argument \"%s\"", type.c_str ()); + return 0; + } if (search_any || search_var) { @@ -682,6 +690,7 @@ %!warning <"class" type argument is not implemented> exist ("a", "class"); %!error exist ("a", 1) %!error exist (1) +%!error exist ("a", "foobar") */