changeset 22182:eb8667f2faac

Fix assignment to an property of an element of classdef array (bug #46660) * ov-classdef.cc (cdef_object_array::subsasgn): Pass at least two dimensions to Array<T>::index (Array<idx_vector>&, ...).
author Lachlan Andrew <lachlanbis@gmail.com>
date Thu, 30 Jun 2016 18:20:37 +1000
parents acdd8983d308
children bfb1b089c230
files libinterp/octave-value/ov-classdef.cc
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-classdef.cc	Mon Jul 25 19:46:33 2016 -0400
+++ b/libinterp/octave-value/ov-classdef.cc	Thu Jun 30 18:20:37 2016 +1000
@@ -1652,7 +1652,7 @@
 
           bool is_scalar = true;
 
-          Array<idx_vector> iv (dim_vector (1, ival.length ()));
+          Array<idx_vector> iv (dim_vector (1, std::max (ival.length (), 2)));
 
           for (int i = 0; i < ival.length (); i++)
             {
@@ -1675,6 +1675,11 @@
                        "array.");
             }
 
+          // Fill in trailing singleton dimensions so that
+          // array.index doesn't create a new blank entry (bug #46660).
+          for (int i = ival.length (); i < 2; i++)
+            iv(i) = 1;
+
           Array<cdef_object> a = array.index (iv, true);
 
           if (a.numel () != 1)