changeset 27143:1bad33112465

Emit an error for invalid fieldnames of 0x0 struct array (bug #34967). * ov-struct.cc (subsref): Always perform dotref() to check that fieldname is valid. Only return a value, however, if map object is not empty.
author Rik <rik@octave.org>
date Tue, 04 Jun 2019 08:10:11 -0700
parents 9e5c1d343a2c
children 142084841f23
files libinterp/octave-value/ov-struct.cc
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-struct.cc	Mon Jun 03 19:03:15 2019 -0700
+++ b/libinterp/octave-value/ov-struct.cc	Tue Jun 04 08:10:11 2019 -0700
@@ -157,12 +157,10 @@
 
     case '.':
       {
-        if (map.numel () > 0)
-          {
-            const Cell t = dotref (idx.front ());
-
-            retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
-          }
+        const Cell t = dotref (idx.front ());
+
+        if (! map.isempty ())
+          retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
       }
       break;