From 2d405baa8a4f3107984317455c65ea73a17c4292 Mon Sep 17 00:00:00 2001 From: LordGrey <48840279+Lord-Grey@users.noreply.github.com> Date: Sun, 1 Dec 2024 16:21:39 +0100 Subject: [PATCH] CodeQL findings --- libsrc/effectengine/EffectModule.cpp | 18 ------------------ libsrc/python/PythonProgram.cpp | 6 ++++-- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/libsrc/effectengine/EffectModule.cpp b/libsrc/effectengine/EffectModule.cpp index 69c01f1f..d3ce4a49 100644 --- a/libsrc/effectengine/EffectModule.cpp +++ b/libsrc/effectengine/EffectModule.cpp @@ -38,24 +38,6 @@ static int hyperion_exec(PyObject* module) { return 0; } -// Module creation function for multi-phase init, used in Py_mod_create slot -static PyObject* hyperion_create(PyModuleDef* def, PyObject* args) { - PyObject* module = PyModule_Create(def); - if (!module) - { - return NULL; - } - - // Execute any additional module initialization logic - if (hyperion_exec(module) < 0) - { - Py_DECREF(module); - return NULL; - } - - return module; -} - // Module deallocation function to clean up per-interpreter state static void hyperion_free(void* /* module */) { diff --git a/libsrc/python/PythonProgram.cpp b/libsrc/python/PythonProgram.cpp index 38a27934..6f0b08c9 100644 --- a/libsrc/python/PythonProgram.cpp +++ b/libsrc/python/PythonProgram.cpp @@ -81,9 +81,11 @@ void PythonProgram::execute(const QByteArray& python_code) { return; } - +#if (PY_VERSION_HEX < 0x030C0000) + PyThreadState_Swap(_tstate); +#else PyThreadState* prev_thread_state = PyThreadState_Swap(_tstate); - +#endif PyObject* main_module = PyImport_ImportModule("__main__"); if (!main_module) {