changeset 28983:6d37fa1a786e stable

Fix loading anonymous function handles with empty local vars (bug #59316). * libinterp/corefcn/ls-mat5.cc (read_mat5_binary_element): Check that octave value is not empty before getting scalar map value.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 21 Oct 2020 22:26:43 +0200
parents a745a046b705
children a6b7085c8ac2 47107a0979cd
files libinterp/corefcn/ls-mat5.cc
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/ls-mat5.cc	Thu Oct 22 11:15:54 2020 -0400
+++ b/libinterp/corefcn/ls-mat5.cc	Wed Oct 21 22:26:43 2020 +0200
@@ -979,20 +979,24 @@
             m2 = subsys_ov.scalar_map_value ();
             m2 = m2.contents ("MCOS").scalar_map_value ();
             tc2 = m2.contents ("MCOS").cell_value ()(1 + off).cell_value ()(1);
-            m2 = tc2.scalar_map_value ();
 
             octave::stack_frame::local_vars_map local_vars;
 
-            if (m2.nfields () > 0)
+            if (! tc2.isempty ())
               {
-                octave_value tmp;
-
-                for (auto p0 = m2.begin (); p0 != m2.end (); p0++)
+                m2 = tc2.scalar_map_value ();
+
+                if (m2.nfields () > 0)
                   {
-                    std::string key = m2.key (p0);
-                    octave_value val = m2.contents (p0);
-
-                    local_vars[key] = val;
+                    octave_value tmp;
+
+                    for (auto p0 = m2.begin (); p0 != m2.end (); p0++)
+                      {
+                        std::string key = m2.key (p0);
+                        octave_value val = m2.contents (p0);
+
+                        local_vars[key] = val;
+                      }
                   }
               }