patch 9.0.1917: undefined behaviour with python function pointer
Problem: undefined behaviour with python function pointer
Solution: correctly cast function pointers from void
Fix more undefined behaviors in if_python
Fix remaining UBSAN errors from Clang 17 in if_python in casting
function pointers.
Also fix a mistake where `PyMem_Free()` should be returning void, by the
dynamic build is mistakenly casting it as a function that returns an
int.
closes: #13128
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
diff --git a/src/if_python.c b/src/if_python.c
index c6b14fe..af5d6c0 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -317,7 +317,7 @@
*/
static int(*dll_PyArg_Parse)(PyObject *, char *, ...);
static int(*dll_PyArg_ParseTuple)(PyObject *, char *, ...);
-static int(*dll_PyMem_Free)(void *);
+static void(*dll_PyMem_Free)(void *);
static void* (*dll_PyMem_Malloc)(size_t);
static int(*dll_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item);
static int(*dll_PyErr_BadArgument)(void);