# HG changeset patch # User Rik # Date 1396821405 25200 # Node ID 60562e5c8bfb96c14f2ca8da669cc02db893f06e # Parent 5fe907167520ba2eef3299834fe5bd4555e10915 Correctly validate arguments to dot function (bug #42061). * dot.cc (Fdot): Check that lengths of vector arguments are the same. Add input validations tests. diff -r 5fe907167520 -r 60562e5c8bfb libinterp/corefcn/dot.cc --- a/libinterp/corefcn/dot.cc Sun Mar 30 23:25:00 2014 +0200 +++ b/libinterp/corefcn/dot.cc Sun Apr 06 14:56:45 2014 -0700 @@ -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 dot ({1,2}, [3,4]) +%!error dot ([1,2], {3,4}) +%!error dot ([1 2], [1 2 3]) +%!error dot ([1 2]', [1 2 3]') +%!error dot (ones (2,2), ones (2,3)) +%!error dot ([1 2], [1 2], 0) */ DEFUN (blkmm, args, ,