Mercurial > hg > octave-nkf
changeset 18784:60562e5c8bfb stable
Correctly validate arguments to dot function (bug #42061).
* dot.cc (Fdot): Check that lengths of vector arguments are the same.
Add input validations tests.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 06 Apr 2014 14:56:45 -0700 |
parents | 5fe907167520 |
children | 5fb180e37d7c |
files | libinterp/corefcn/dot.cc |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/dot.cc +++ b/libinterp/corefcn/dot.cc @@ -142,7 +142,7 @@ argx = argx.reshape (dimx); dimy = dimy.redim (1); argy = argy.reshape (dimy); - match = ! error_state; + match = ! error_state && (dimx == dimy); } if (match) @@ -262,6 +262,16 @@ %! assert (dot (x, y, 2), [17; 53]); %! assert (dot (x, y, 3), [5 12; 21 32]); +%% Test input validation +%!error dot () +%!error dot (1) +%!error dot (1,2,3,4) +%!error <X and Y must be numeric> dot ({1,2}, [3,4]) +%!error <X and Y must be numeric> dot ([1,2], {3,4}) +%!error <sizes of X and Y must match> dot ([1 2], [1 2 3]) +%!error <sizes of X and Y must match> dot ([1 2]', [1 2 3]') +%!error <sizes of X and Y must match> dot (ones (2,2), ones (2,3)) +%!error <DIM must be a valid dimension> dot ([1 2], [1 2], 0) */ DEFUN (blkmm, args, ,