changeset 32213:3321783e9fe5 stable

ellipsoid.m: Prevent geometry data return when not requested (bug #64468) * scripts/plot/draw/ellipsoid.m: Change return variables from xx,yy,zz to x,y,z so that nothing is returned unless the nargout > 0 condition is met. Add BISTs to verify behavior and ensure ans is not overwritten when nargout=0. Remove optional variable N from first deftypefn definition. * etc/NEWS.8.md: Add bugfix note to 8.3.0 Improvements and fixes section.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Mon, 24 Jul 2023 13:30:54 -0400
parents 591c39fb7bca
children bc17da3679d8 ce1ae40de0f0
files etc/NEWS.8.md scripts/plot/draw/ellipsoid.m
diffstat 2 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS.8.md	Wed Jul 19 14:01:46 2023 +0200
+++ b/etc/NEWS.8.md	Mon Jul 24 13:30:54 2023 -0400
@@ -4,6 +4,8 @@
 For (bug #XXXXX) see https://savannah.gnu.org/bugs/?XXXXX
 
 ### Improvements and fixes
+- `ellipsoid.m`: avoid returning geometry data unless it is explicitly
+requested to avoid overwriting `ans`.
 
 ### GUI
 
--- a/scripts/plot/draw/ellipsoid.m	Wed Jul 19 14:01:46 2023 +0200
+++ b/scripts/plot/draw/ellipsoid.m	Mon Jul 24 13:30:54 2023 -0400
@@ -24,7 +24,7 @@
 ########################################################################
 
 ## -*- texinfo -*-
-## @deftypefn  {} {} ellipsoid (@var{xc}, @var{yc}, @var{zc}, @var{xr}, @var{yr}, @var{zr}, @var{n})
+## @deftypefn  {} {} ellipsoid (@var{xc}, @var{yc}, @var{zc}, @var{xr}, @var{yr}, @var{zr})
 ## @deftypefnx {} {} ellipsoid (@dots{}, @var{n})
 ## @deftypefnx {} {} ellipsoid (@var{hax}, @dots{})
 ## @deftypefnx {} {[@var{x}, @var{y}, @var{z}] =} ellipsoid (@dots{})
@@ -45,7 +45,7 @@
 ## @seealso{cylinder, rectangle, sphere}
 ## @end deftypefn
 
-function [xx, yy, zz] = ellipsoid (varargin)
+function [x, y, z] = ellipsoid (varargin)
 
   [hax, varargin, nargin] = __plt_get_axis_arg__ ("ellipsoid", varargin{:});
 
@@ -106,6 +106,19 @@
 %! ellipsoid (0, 0, 1, 2, 3, 4, 20);
 %! title ("ellipsoid()");
 
+%!test <*64468> # No return if nargout = 0
+%! hf = figure ("visible", "off");
+%! hax = gca ();
+%! unwind_protect
+%!   1 + 1;
+%!   assert (ans, 2);
+%!   ellipsoid (hax, 0, 0, 0, 1, 1, 1);
+%!   assert (ans, 2);
+%!
+%!  unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
+
 ## Test input validation
 %!error <Invalid call> ellipsoid (1,2,3,4,5)
 %!error <Invalid call> ellipsoid (1,2,3,4,5,6,7,8)