comparison scripts/plot/surfnorm.m @ 10634:60542efcfa2c

Check input arguments for size and type (bug #29861). Prevents segmentation fault with odd inputs.
author Rik <octave@nomad.inbox5.com>
date Sun, 16 May 2010 18:28:59 -0700
parents 95c3e38098bf
children be55736a0783
comparison
equal deleted inserted replaced
10633:d022061c288d 10634:60542efcfa2c
69 y = varargin{2}; 69 y = varargin{2};
70 z = varargin{3}; 70 z = varargin{3};
71 ioff = 4; 71 ioff = 4;
72 endif 72 endif
73 73
74 if (nargout == 0) 74 if (!ismatrix (z) || isvector (z) || isscalar (z))
75 error ("surfnorm: z argument must be a matrix");
75 endif 76 endif
77 if (! size_equal (x, y, z))
78 error ("surfnorm: x, y, and z must have the same dimensions");
79 endif
76 80
77 ## Make life easier, and avoid having to do the extrapolation later, do 81 ## Make life easier, and avoid having to do the extrapolation later, do
78 ## a simpler linear extrapolation here. This is approximative, and works 82 ## a simpler linear extrapolation here. This is approximative, and works
79 ## badly for closed surfaces like spheres. 83 ## badly for closed surfaces like spheres.
80 xx = [2 .* x(:,1) - x(:,2), x, 2 .* x(:,end) - x(:,end-1)]; 84 xx = [2 .* x(:,1) - x(:,2), x, 2 .* x(:,end) - x(:,end-1)];