1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Reset PyObject pointers to NULL when deinitializing.

cleanup_python and python_done_keybinding_interface called by it
now reset the PyObject *python_hooks, *keybindings variables back
to NULL when they release the references.  Without this change,
dangling pointers left in those variables could cause problems
if the Python scripting module were deinitialized and reinitialized.
It looks like such reinitialization is not currently possible though,
because enhancement request 73 (plugins support) has not yet been
implemented.
This commit is contained in:
M. Levinson 2006-12-10 13:02:34 -05:00 committed by Kalle Olavi Niemitalo
parent 47d27a4d39
commit b6d14e025c
2 changed files with 16 additions and 2 deletions

View File

@ -209,8 +209,16 @@ void
cleanup_python(struct module *module)
{
if (Py_IsInitialized()) {
PyObject *temp;
python_done_keybinding_interface();
Py_XDECREF(python_hooks);
/* This is equivalent to Py_CLEAR(), but it works with older
* versions of Python predating that macro: */
temp = python_hooks;
python_hooks = NULL;
Py_XDECREF(temp);
Py_Finalize();
}
}

View File

@ -194,5 +194,11 @@ python_init_keybinding_interface(PyObject *dict, PyObject *name)
void
python_done_keybinding_interface(void)
{
Py_XDECREF(keybindings);
PyObject *temp;
/* This is equivalent to Py_CLEAR(), but it works with older
* versions of Python predating that macro: */
temp = keybindings;
keybindings = NULL;
Py_XDECREF(temp);
}