[libpeas] Fix a crash in the Python loader if Python initialisation failed



commit c6aaf6f75ddd7676d23462975f34ecbbf7f637a7
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Jun 30 19:13:52 2010 +0100

    Fix a crash in the Python loader if Python initialisation failed
    
    The loader would try to acquire the Python GIL when adding a module directory,
    which would cause a crash.

 loaders/python/peas-plugin-loader-python.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index f5c5bbd..8706cd2 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -244,7 +244,14 @@ peas_plugin_loader_python_add_module_directory (PeasPluginLoader *loader,
                                                 const gchar      *module_dir)
 {
   PeasPluginLoaderPython *pyloader = PEAS_PLUGIN_LOADER_PYTHON (loader);
-  PyGILState_STATE state = pyg_gil_state_ensure ();
+  PyGILState_STATE state;
+
+  /* Bail if we failed to initialise Python, since adding a module path won't
+   * help us, and calling the GIL functions will cause a crash. */
+  if (pyloader->priv->init_failed)
+    return;
+
+  state = pyg_gil_state_ensure ();
 
   g_debug ("Adding %s as a module path for the python loader.", module_dir);
   peas_plugin_loader_python_add_module_path (pyloader, module_dir);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]