Mercurial > hg > octave-lojdl
changeset 9124:47f19c11b558
fix checking valid range subscripts
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 16 Apr 2009 08:06:38 +0200 |
parents | f39b98237d5c |
children | 8ab1e6f63cdc |
files | liboctave/ChangeLog liboctave/idx-vector.cc |
diffstat | 2 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2009-04-16 Jaroslav Hajek <highegg@gmail.com> + + * idx-vector.cc (idx_vector::idx_range_rep::idx_range_rep (const + Range&)): Check for positive integer indices. Unify gripes. + 2009-04-15 Jaroslav Hajek <highegg@gmail.com> * Array.cc (rec_permute_helper::blk_trans): Declare as static.
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -108,13 +108,6 @@ } } -static void -gripe_non_int_range (void) -{ - (*current_liboctave_error_handler) - ("If a range is used as subscript, all elements are expected to be integers."); -} - idx_vector::idx_range_rep::idx_range_rep (const Range& r) : start (0), len (r.nelem ()), step (1) { @@ -129,10 +122,15 @@ { start = static_cast<octave_idx_type> (r.base ()) - 1; step = static_cast<octave_idx_type> (r.inc ()); + if (start < 0 || (step < 0 && start + (len-1)*step < 0)) + { + gripe_invalid_index (); + err = true; + } } else { - gripe_non_int_range (); + gripe_invalid_index (); err = true; } }