Mercurial > hg > octave-lyh
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 +++ b/src/oct-map.cc @@ -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 {