patch 9.0.1913: if_python: undefined behaviour for function pointers

Commit: 
https://github.com/vim/vim/commit/2ce070c27acd12ccc614afa4cecf4970a645a4af
Author: Yee Cheng Chin <ychin....@gmail.com>
Date:   Tue Sep 19 20:30:22 2023 +0200

    patch 9.0.1913: if_python: undefined behaviour for function pointers
    
    Problem:  if_python: undefined behaviour for function pointers
    Solution: Fix if_python undefined behavior for function pointer casts
    
    Identified by clang 17 UBSAN (see #12745). Make sure to cast function
    pointers with the same signature only.
    
    closes: #13122
    
    Signed-off-by: Christian Brabandt <c...@256bit.org>
    Co-authored-by: Yee Cheng Chin <ychin....@gmail.com>

diff --git a/src/if_py_both.h b/src/if_py_both.h
index 6e2ef26e7..0723a5ff9 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -5962,14 +5962,15 @@ static struct PyMethodDef CurrentMethods[] = {
 };
 
     static void
-init_range_cmd(exarg_T *eap)
+init_range_cmd(void *arg)
 {
+    exarg_T *eap = (exarg_T*)arg;
     RangeStart = eap->line1;
     RangeEnd = eap->line2;
 }
 
     static void
-init_range_eval(typval_T *rettv UNUSED)
+init_range_eval(void *rettv UNUSED)
 {
     RangeStart = (PyInt) curwin->w_cursor.lnum;
     RangeEnd = RangeStart;
diff --git a/src/if_python.c b/src/if_python.c
index 863e9319d..c6b14fec2 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -1103,7 +1103,7 @@ ex_python(exarg_T *eap)
            p_pyx = 2;
 
        DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script,
-               (rangeinitializer) init_range_cmd,
+               init_range_cmd,
                (runner) run_cmd,
                (void *) eap);
     }
@@ -1154,7 +1154,7 @@ ex_pyfile(exarg_T *eap)
 
     // Execute the file
     DoPyCommand(buffer,
-           (rangeinitializer) init_range_cmd,
+           init_range_cmd,
            (runner) run_cmd,
            (void *) eap);
 }
@@ -1166,7 +1166,7 @@ ex_pydo(exarg_T *eap)
        p_pyx = 2;
 
     DoPyCommand((char *)eap->arg,
-           (rangeinitializer) init_range_cmd,
+           init_range_cmd,
            (runner)run_do,
            (void *)eap);
 }
@@ -1524,7 +1524,7 @@ FunctionGetattr(PyObject *self, char *name)
 do_pyeval(char_u *str, typval_T *rettv)
 {
     DoPyCommand((char *) str,
-           (rangeinitializer) init_range_eval,
+           init_range_eval,
            (runner) run_eval,
            (void *) rettv);
     if (rettv->v_type == VAR_UNKNOWN)
diff --git a/src/if_python3.c b/src/if_python3.c
index c6d1acc19..d2ffada0c 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -1425,7 +1425,7 @@ ex_py3(exarg_T *eap)
            p_pyx = 3;
 
        DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script,
-               (rangeinitializer) init_range_cmd,
+               init_range_cmd,
                (runner) run_cmd,
                (void *) eap);
     }
@@ -1491,7 +1491,7 @@ ex_py3file(exarg_T *eap)
 
     // Execute the file
     DoPyCommand(buffer,
-           (rangeinitializer) init_range_cmd,
+           init_range_cmd,
            (runner) run_cmd,
            (void *) eap);
 }
@@ -1503,7 +1503,7 @@ ex_py3do(exarg_T *eap)
        p_pyx = 3;
 
     DoPyCommand((char *)eap->arg,
-           (rangeinitializer)init_range_cmd,
+           init_range_cmd,
            (runner)run_do,
            (void *)eap);
 }
@@ -2053,7 +2053,7 @@ LineToString(const char *str)
 do_py3eval(char_u *str, typval_T *rettv)
 {
     DoPyCommand((char *) str,
-           (rangeinitializer) init_range_eval,
+           init_range_eval,
            (runner) run_eval,
            (void *) rettv);
     if (rettv->v_type == VAR_UNKNOWN)
diff --git a/src/version.c b/src/version.c
index 42ac8083b..c43b28f37 100644
--- a/src/version.c
+++ b/src/version.c
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1913,
 /**/
     1912,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1qifib-002Iuw-3u%40256bit.org.

Raspunde prin e-mail lui