Mercurial > hg > octave-nkf
changeset 10620:6fb954475e21
fix off-by-1 error in idx_vector (bug #29851)
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 11 May 2010 07:25:20 +0200 |
parents | 9f0a264d2f60 |
children | 483dbafc518c |
files | liboctave/ChangeLog liboctave/idx-vector.cc |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +2010-05-11 Jaroslav Hajek <highegg@gmail.com> + + * idx-vector.cc (idx_vector::unmask): Fix off-by-1 bug. Add tests. + 2010-05-06 Jaroslav Hajek <highegg@gmail.com> * Array.cc (Array::delete_elements (const idx_vector&)): Only call
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -1202,7 +1202,7 @@ if (data[i]) idata[j++] = i; - ext = len > 0 ? idata[len - 1] : 0; + ext = len > 0 ? idata[len - 1] + 1 : 0; return new idx_vector_rep (idata, len, ext, r->orig_dimensions (), DIRECT); @@ -1313,3 +1313,10 @@ INSTANTIATE_SCALAR_VECTOR_REP_CONST (octave_uint16) INSTANTIATE_SCALAR_VECTOR_REP_CONST (octave_uint32) INSTANTIATE_SCALAR_VECTOR_REP_CONST (octave_uint64) + +/* + +%!error id=Octave:index-out-of-bounds 1(find([1,1] != 0)) +%!assert ((1:3)(find([1,0,1] != 0)), [1,3]) + +*/