This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new 962c05b python: Fix sanlock.SanlockException initialization
962c05b is described below
commit 962c05b3328abfe5d86a8437a770cdc0c6eb914c
Author: Nir Soffer <nirsof(a)gmail.com>
AuthorDate: Wed May 1 18:52:20 2019 +0300
python: Fix sanlock.SanlockException initialization
If PyModule_AddObject() failed, an exception was set, and we must
return. The code importing the module will fail with the set exception.
While fixing this issue, use more standard code for handling global
python objects:
- Always increase error reference, to make sure the gloabl does not
become dangling pointer if sanlock.SanlockException is modified by the
application.
- If PyModule_AddObject() fails, decrease the referene.
- If the module is reloaded, do not create a new SanlockException object
and leak the previous object.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 2ad4497..a9c4cf6 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1616,13 +1616,16 @@ initsanlock(void)
if (py_module == NULL)
return;
- py_exception = initexception();
+ if (py_exception == NULL) {
+ py_exception = initexception();
+ if (py_exception == NULL)
+ return;
+ }
- if (py_exception == NULL)
+ Py_INCREF(py_exception);
+ if (PyModule_AddObject(py_module, "SanlockException", py_exception)) {
+ Py_DECREF(py_exception);
return;
-
- if (PyModule_AddObject(py_module, "SanlockException", py_exception) == 0)
{
- Py_INCREF(py_exception);
}
#define PYSNLK_INIT_ADD_CONSTANT(x, y) \
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date