]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1765: f_isnan() and f_isinf() do not correctly initialize rettv type v9.1.1765
authorDamien Lejay <damien@lejay.be>
Mon, 15 Sep 2025 19:55:25 +0000 (19:55 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 15 Sep 2025 19:55:25 +0000 (19:55 +0000)
Problem:  f_isnan() and f_isinf() do not correctly initialize rettv type
Solution: Initialize them with type: VAR_NUMBER and value 0 (Damien Lejay).

Both builtins wrote only rettv->vval.v_number and relied on call_func()
initialising rettv->v_type to VAR_NUMBER.  Explicitly set

    rettv->v_type = VAR_NUMBER;
    rettv->vval.v_number = 0;

at function entry to avoid undefined behaviour and make the return type
self-contained.

closes: #18307

Signed-off-by: Damien Lejay <damien@lejay.be>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/float.c
src/version.c

index 4c8e5fe10ad9cc21980ae58816bc9b8a2791a3df..fcdaaefa99dbaefd97a07119421fcb7ee9671ada 100644 (file)
@@ -345,6 +345,9 @@ f_fmod(typval_T *argvars, typval_T *rettv)
     void
 f_isinf(typval_T *argvars, typval_T *rettv)
 {
+    rettv->v_type = VAR_NUMBER;
+    rettv->vval.v_number = 0;
+
     if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
        return;
 
@@ -358,6 +361,9 @@ f_isinf(typval_T *argvars, typval_T *rettv)
     void
 f_isnan(typval_T *argvars, typval_T *rettv)
 {
+    rettv->v_type = VAR_NUMBER;
+    rettv->vval.v_number = 0;
+
     if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
        return;
 
index 1e231bf31f508e6cf613d6fef38b4be446727222..f58befda0024fc69229b3b0dbc773472cb255b2b 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1765,
 /**/
     1764,
 /**/