Mercurial > octave
changeset 27249:84cdeeaf0dce
Accept only integers for single input form of rand (bug #56609).
* rand.cc: Use idx_type_value(true) rather than double_value() to convert input
octave_value to integer size of output array.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 12 Jul 2019 19:55:03 -0700 |
parents | a23f25cc2aae |
children | 42fd0e3121f7 |
files | libinterp/corefcn/rand.cc |
diffstat | 1 files changed, 2 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/rand.cc Fri Jul 12 17:20:07 2019 -0700 +++ b/libinterp/corefcn/rand.cc Fri Jul 12 19:55:03 2019 -0700 @@ -170,14 +170,11 @@ } else if (tmp.is_scalar_type ()) { - double dval = tmp.double_value (); - - if (octave::math::isnan (dval)) - error ("%s: NaN is invalid matrix dimension", fcn); + octave_idx_type n = tmp.idx_type_value (true); dims.resize (2); - dims(0) = dims(1) = octave::math::nint_big (dval); + dims(0) = dims(1) = n; goto gen_matrix; }