[libpeas] Fix two leaks in the Python plugin loader



commit a46316bef89bca5198ad58f82d1ea1753463425d
Author: Garrett Regier <alias301 gmail com>
Date:   Fri Mar 4 23:57:36 2011 -0800

    Fix two leaks in the Python plugin loader

 loaders/python/peas-plugin-loader-python.c |   36 ++++++++++++++-------------
 1 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index ddfa949..9246601 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -83,25 +83,25 @@ find_python_extension_type (PeasPluginInfo *info,
   pytype = PyObject_GetAttrString (pygtype, "pytype");
   g_return_val_if_fail (pytype != NULL, NULL);
 
-  if (pytype == Py_None)
-    return NULL;
-
-  while (PyDict_Next (locals, &pos, &key, &value))
+  if (pytype != Py_None)
     {
-      if (!PyType_Check (value))
-        continue;
-
-      switch (PyObject_IsSubclass (value, pytype))
+      while (PyDict_Next (locals, &pos, &key, &value))
         {
-        case 1:
-          Py_DECREF (pygtype);
-          return (PyTypeObject *) value;
-        case 0:
-          continue;
-        case -1:
-        default:
-          PyErr_Print ();
-          continue;
+          if (!PyType_Check (value))
+            continue;
+
+          switch (PyObject_IsSubclass (value, pytype))
+            {
+            case 1:
+              Py_DECREF (pygtype);
+              return (PyTypeObject *) value;
+            case 0:
+              continue;
+            case -1:
+            default:
+              PyErr_Print ();
+              continue;
+            }
         }
     }
 
@@ -301,6 +301,8 @@ peas_plugin_loader_python_load (PeasPluginLoader *loader,
 
   add_python_info (pyloader, info, pymodule);
 
+  Py_DECREF (pymodule);
+
   pyg_gil_state_release (state);
 
   return TRUE;



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