# HG changeset patch # User Rik # Date 1523565050 25200 # Node ID c64f7a95b464242a94d2b67a929f6ee585a35f7f # Parent 8a92b651838b204b3b28cf7a22500f48b1f1d25a pie.m, pie3.m: Validate that data input is finite (bug #53480). * pie.m, pie3.m: Use isfinite() to check input data X. Add BIST tests for input validation. diff -r 8a92b651838b -r c64f7a95b464 scripts/plot/draw/pie.m --- a/scripts/plot/draw/pie.m Thu Apr 12 13:19:25 2018 -0700 +++ b/scripts/plot/draw/pie.m Thu Apr 12 13:30:50 2018 -0700 @@ -60,6 +60,10 @@ print_usage (); endif + if (! all (isfinite (varargin{1}))) + error ("pie: all data in X must be finite"); + endif + oldfig = []; if (! isempty (hax)) oldfig = get (0, "currentfigure"); @@ -100,3 +104,8 @@ %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %! axis ([-2,2,-2,2]); %! title ("pie() with missing slice"); + +## Test input validation +%!error pie () +%!error pie ([1 2 Inf]) +%!error pie ([1 2 NaN]) diff -r 8a92b651838b -r c64f7a95b464 scripts/plot/draw/pie3.m --- a/scripts/plot/draw/pie3.m Thu Apr 12 13:19:25 2018 -0700 +++ b/scripts/plot/draw/pie3.m Thu Apr 12 13:30:50 2018 -0700 @@ -61,6 +61,10 @@ print_usage (); endif + if (! all (isfinite (varargin{1}))) + error ("pie3: all data in X must be finite"); + endif + oldfig = []; if (! isempty (hax)) oldfig = get (0, "currentfigure"); @@ -100,3 +104,8 @@ %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); %! axis ([-2,2,-2,2]); %! title ("pie3() with missing slice"); + +## Test input validation +%!error pie3 () +%!error pie3 ([1 2 Inf]) +%!error pie3 ([1 2 NaN])