From: Gilchrist Dadaglo Date: Tue, 8 Dec 2020 14:37:07 +0000 (+0000) Subject: BUG/MAJOR: spoa/python: Fixing return None X-Git-Tag: v2.4-dev3~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5c428e761796317fdfa9c7f9bf3f6280e218a98;p=thirdparty%2Fhaproxy.git BUG/MAJOR: spoa/python: Fixing return None As per https://docs.python.org/3/c-api/none.html, None requires to be incremented before being returned to prevent deallocating none This patch must be backported as far as 2.0. --- diff --git a/contrib/spoa_server/ps_python.c b/contrib/spoa_server/ps_python.c index 5cb7ca86e2..81bb932532 100644 --- a/contrib/spoa_server/ps_python.c +++ b/contrib/spoa_server/ps_python.c @@ -90,7 +90,7 @@ static PyObject *ps_python_register_message(PyObject *self, PyObject *args) ps_register_message(&ps_python_bindings, name, (void *)ref); - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_null(PyObject *self, PyObject *args) @@ -109,7 +109,7 @@ static PyObject *ps_python_set_var_null(PyObject *self, PyObject *args) PyErr_SetString(spoa_error, "No space left available"); return NULL; } - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_boolean(PyObject *self, PyObject *args) @@ -129,7 +129,7 @@ static PyObject *ps_python_set_var_boolean(PyObject *self, PyObject *args) PyErr_SetString(spoa_error, "No space left available"); return NULL; } - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_int32(PyObject *self, PyObject *args) @@ -149,7 +149,7 @@ static PyObject *ps_python_set_var_int32(PyObject *self, PyObject *args) PyErr_SetString(spoa_error, "No space left available"); return NULL; } - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_uint32(PyObject *self, PyObject *args) @@ -169,7 +169,7 @@ static PyObject *ps_python_set_var_uint32(PyObject *self, PyObject *args) PyErr_SetString(spoa_error, "No space left available"); return NULL; } - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_int64(PyObject *self, PyObject *args) @@ -189,7 +189,7 @@ static PyObject *ps_python_set_var_int64(PyObject *self, PyObject *args) PyErr_SetString(spoa_error, "No space left available"); return NULL; } - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_uint64(PyObject *self, PyObject *args) @@ -209,7 +209,7 @@ static PyObject *ps_python_set_var_uint64(PyObject *self, PyObject *args) PyErr_SetString(spoa_error, "No space left available"); return NULL; } - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_ipv4(PyObject *self, PyObject *args) @@ -246,7 +246,7 @@ static PyObject *ps_python_set_var_ipv4(PyObject *self, PyObject *args) } /* Once we set the IP value in the worker, we don't need it anymore... */ Py_XDECREF(value); - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_ipv6(PyObject *self, PyObject *args) @@ -283,7 +283,7 @@ static PyObject *ps_python_set_var_ipv6(PyObject *self, PyObject *args) } /* Once we set the IP value in the worker, we don't need it anymore... */ Py_XDECREF(value); - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_str(PyObject *self, PyObject *args) @@ -306,7 +306,7 @@ static PyObject *ps_python_set_var_str(PyObject *self, PyObject *args) PyErr_SetString(spoa_error, "No space left available"); return NULL; } - return Py_None; + Py_RETURN_NONE; } static PyObject *ps_python_set_var_bin(PyObject *self, PyObject *args) @@ -329,7 +329,7 @@ static PyObject *ps_python_set_var_bin(PyObject *self, PyObject *args) PyErr_SetString(spoa_error, "No space left available"); return NULL; } - return Py_None; + Py_RETURN_NONE; }