changeset 18899:a0fd65914811

Fix segfault in exist() when checking faulty mex/oct files (bug #36067). * variables.cc (symbol_exist): Wrap symbol table lookup in try/catch block.
author Rik <rik@octave.org>
date Thu, 26 Jun 2014 09:33:38 -0700
parents c677d9bd6bac
children 2b82d2f29a7b
files libinterp/corefcn/variables.cc
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/variables.cc	Thu Jun 26 09:02:01 2014 -0700
+++ b/libinterp/corefcn/variables.cc	Thu Jun 26 09:33:38 2014 -0700
@@ -418,7 +418,12 @@
 
   if (search_any || search_builtin)
     {
-      val = safe_symbol_lookup (name);
+      // Require a try block because symbol_lookup will attempt unsafe load
+      // of .oct/.mex file.
+      try
+        { val = safe_symbol_lookup (name); }
+      catch (octave_execution_exception)
+        { }
 
       if (val.is_defined () && val.is_builtin_function ())
         return 5;
@@ -462,7 +467,7 @@
             if (fs.is_dir ())
               return 7;
 
-            size_t len = file_name.length ();
+            len = file_name.length ();
 
             if (len > 4 && (file_name.substr (len-4) == ".oct"
                             || file_name.substr (len-4) == ".mex"))