sudo_module_register_loghandler: clear sudo_type_LogHandler on error
Also add comments about PyModule_AddObject stealing a ref on success.
This commit is contained in:
@@ -74,6 +74,7 @@ sudo_module_register_baseplugin(PyObject *py_module)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// PyModule_AddObject steals a reference to py_class on success
|
||||
Py_INCREF(py_class);
|
||||
rc = SUDO_RC_OK;
|
||||
|
||||
|
@@ -91,6 +91,7 @@ sudo_module_register_conv_message(PyObject *py_module)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// PyModule_AddObject steals the reference to py_class on success
|
||||
Py_INCREF(py_class);
|
||||
rc = SUDO_RC_OK;
|
||||
|
||||
|
@@ -148,9 +148,12 @@ sudo_module_register_loghandler(PyObject *py_module)
|
||||
if (sudo_type_LogHandler == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if (PyModule_AddObject(py_module, "LogHandler", sudo_type_LogHandler) < 0)
|
||||
if (PyModule_AddObject(py_module, "LogHandler", sudo_type_LogHandler) < 0) {
|
||||
Py_CLEAR(sudo_type_LogHandler);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// PyModule_AddObject steals a reference to sudo_type_LogHandler on success
|
||||
Py_INCREF(sudo_type_LogHandler);
|
||||
|
||||
cleanup:
|
||||
|
@@ -479,7 +479,6 @@ sudo_module_register_enum(PyObject *py_module, const char *enum_name, PyObject *
|
||||
return;
|
||||
|
||||
PyObject *py_enum_class = NULL;
|
||||
{
|
||||
PyObject *py_enum_module = PyImport_ImportModule("enum");
|
||||
if (py_enum_module == NULL) {
|
||||
Py_CLEAR(py_constants_dict);
|
||||
@@ -492,15 +491,14 @@ sudo_module_register_enum(PyObject *py_module, const char *enum_name, PyObject *
|
||||
|
||||
Py_CLEAR(py_constants_dict);
|
||||
Py_CLEAR(py_enum_module);
|
||||
}
|
||||
|
||||
if (py_enum_class == NULL) {
|
||||
debug_return;
|
||||
}
|
||||
|
||||
// PyModule_AddObject steals the reference to py_enum_class on success
|
||||
if (PyModule_AddObject(py_module, enum_name, py_enum_class) < 0) {
|
||||
Py_CLEAR(py_enum_class);
|
||||
debug_return;
|
||||
}
|
||||
|
||||
debug_return;
|
||||
|
Reference in New Issue
Block a user