changeset 33578:3e446791b7ef

Fix some more silent acceptance of fractional inputs (bug #65730) Change most remaining instances of nint_value to strict_int_value. This prevents silent acceptance for fractional values for dimension, length, etc, as described in bug #65730. Files updated: filter.cc, __eigs__.cc, cellfun.cc, pr-output.cc
author Arun Giridhar <arungiridhar@gmail.com>
date Sun, 12 May 2024 21:00:35 -0400
parents 273cf7c2302a
children 396481f4e261 de14d508b8f9
files libinterp/corefcn/__eigs__.cc libinterp/corefcn/cellfun.cc libinterp/corefcn/filter.cc libinterp/corefcn/pr-output.cc
diffstat 4 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__eigs__.cc	Sat May 11 18:48:00 2024 -0400
+++ b/libinterp/corefcn/__eigs__.cc	Sun May 12 21:00:35 2024 -0400
@@ -238,7 +238,7 @@
       if (nargin < 2)
         error ("eigs: incorrect number of arguments");
 
-      n = args(1).nint_value ();
+      n = args(1).strict_int_value ();
       arg_offset = 1;
       have_a_fcn = true;
     }
@@ -304,7 +304,7 @@
     }
 
   if (nargin > (1+arg_offset))
-    k = args(1+arg_offset).nint_value ();
+    k = args(1+arg_offset).strict_int_value ();
 
   if (nargin > (2+arg_offset))
     {
@@ -368,11 +368,11 @@
 
       tmp = map.getfield ("maxit");
       if (tmp.is_defined ())
-        maxit = tmp.nint_value ();
+        maxit = tmp.strict_int_value ();
 
       tmp = map.getfield ("p");
       if (tmp.is_defined ())
-        p = tmp.nint_value ();
+        p = tmp.strict_int_value ();
 
       tmp = map.getfield ("v0");
       if (tmp.is_defined ())
@@ -385,7 +385,7 @@
 
       tmp = map.getfield ("disp");
       if (tmp.is_defined ())
-        disp = tmp.nint_value ();
+        disp = tmp.strict_int_value ();
 
       tmp = map.getfield ("cholB");
       if (tmp.is_defined ())
--- a/libinterp/corefcn/cellfun.cc	Sat May 11 18:48:00 2024 -0400
+++ b/libinterp/corefcn/cellfun.cc	Sun May 12 21:00:35 2024 -0400
@@ -188,7 +188,7 @@
       if (nargin != 3)
         error (R"(cellfun: not enough arguments for "size")");
 
-      int d = args(2).nint_value () - 1;
+      int d = args(2).strict_int_value () - 1;
 
       if (d < 0)
         error ("cellfun: K must be a positive integer");
--- a/libinterp/corefcn/filter.cc	Sat May 11 18:48:00 2024 -0400
+++ b/libinterp/corefcn/filter.cc	Sun May 12 21:00:35 2024 -0400
@@ -373,7 +373,7 @@
 
   if (nargin == 5)
     {
-      dim = args(4).nint_value () - 1;
+      dim = args(4).strict_int_value () - 1;
       if (dim < 0 || dim >= x_dims.ndims ())
         error ("filter: DIM must be a valid dimension");
     }
--- a/libinterp/corefcn/pr-output.cc	Sat May 11 18:48:00 2024 -0400
+++ b/libinterp/corefcn/pr-output.cc	Sun May 12 21:00:35 2024 -0400
@@ -3251,7 +3251,7 @@
 
   rat_string_len = 13;
   if (nargin == 2)
-    rat_string_len = args(1).nint_value ();
+    rat_string_len = args(1).strict_int_value ();
 
   frame.protect_var (rat_format);