changeset 13968:241f68fb48c3

octave_map::cat: avoid indexing beyond end of array * oct-map.cc (octave_map::cat (int, octave_idx_type, const octave_map*)): Skip check for all fields being the same if there are no fields.
author John W. Eaton <jwe@octave.org>
date Thu, 01 Dec 2011 03:15:43 -0500
parents 9ff0273cd054
children 3b5afcec526b
files src/oct-map.cc
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/oct-map.cc	Wed Nov 30 16:13:52 2011 -0800
+++ b/src/oct-map.cc	Thu Dec 01 03:15:43 2011 -0500
@@ -755,14 +755,19 @@
 
       // Try the fast case.
       bool all_same = true;
-      for (octave_idx_type i = 0; i < n; i++)
+
+      if (nf > 0)
         {
-          all_same = map_list[idx].xkeys.is_same (map_list[i].xkeys);
-          if (! all_same)
-            break;
+          for (octave_idx_type i = 0; i < n; i++)
+            {
+              all_same = map_list[idx].xkeys.is_same (map_list[i].xkeys);
+
+              if (! all_same)
+                break;
+            }
         }
 
-      if (all_same)
+      if (all_same && nf > 0)
         do_cat (dim, n, map_list, retval);
       else
         {