summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/plugin.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-02-09 13:01:58 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-02-09 13:01:58 (GMT)
commit5863af232b8fc57de210702afe659a7383bb8840 (patch)
tree18e6fd0fb7be2f01d23cda34f8d7b3f29b1a250b /plugins/pychrysalide/plugin.c
parent32bef30025f5e3f513c2b4936c0573cc3b629961 (diff)
Fixed another batch of memory leaks.
Diffstat (limited to 'plugins/pychrysalide/plugin.c')
-rw-r--r--plugins/pychrysalide/plugin.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c
index 51da910..9352924 100644
--- a/plugins/pychrysalide/plugin.c
+++ b/plugins/pychrysalide/plugin.c
@@ -94,9 +94,6 @@ struct _GPythonPlugin
{
GPluginModule parent; /* Instance parente */
- PyObject *module; /* Script Python chargé */
- PyObject *instance; /* Instance Python du greffon */
-
};
@@ -551,6 +548,8 @@ static void py_plugin_module_handle_binary_content_wrapper(const GPluginModule *
Py_XDECREF(value);
Py_DECREF(args);
+ Py_DECREF(pyobj);
+
PyGILState_Release(gstate);
}
@@ -597,6 +596,8 @@ static void py_plugin_module_handle_loaded_content_wrapper(const GPluginModule *
Py_XDECREF(value);
Py_DECREF(args);
+ Py_DECREF(pyobj);
+
PyGILState_Release(gstate);
}
@@ -643,6 +644,8 @@ static bool py_plugin_module_handle_binary_format_analysis_wrapper(const GPlugin
Py_XDECREF(value);
Py_DECREF(args);
+ Py_DECREF(pyobj);
+
PyGILState_Release(gstate);
return true;
@@ -691,6 +694,8 @@ static bool py_plugin_module_preload_binary_format_wrapper(const GPluginModule *
Py_XDECREF(value);
Py_DECREF(args);
+ Py_DECREF(pyobj);
+
PyGILState_Release(gstate);
return true;
@@ -735,6 +740,8 @@ static void py_plugin_module_attach_debug_format_wrapper(const GPluginModule *pl
Py_XDECREF(value);
Py_DECREF(args);
+ Py_DECREF(pyobj);
+
PyGILState_Release(gstate);
}
@@ -781,6 +788,8 @@ static void py_plugin_module_process_disassembly_event_wrapper(const GPluginModu
Py_XDECREF(value);
Py_DECREF(args);
+ Py_DECREF(pyobj);
+
PyGILState_Release(gstate);
}
@@ -903,9 +912,6 @@ static void g_python_plugin_dispose(GPythonPlugin *plugin)
if (tstate != NULL)
PyEval_RestoreThread(tstate);
- Py_XDECREF(plugin->instance);
- plugin->instance = NULL;
-
if (tstate != NULL)
PyEval_SaveThread();
@@ -930,15 +936,20 @@ static void g_python_plugin_finalize(GPythonPlugin *plugin)
{
plugin_interface *final; /* Interface finale conservée */
- Py_XDECREF(plugin->module);
-
final = (plugin_interface *)G_PLUGIN_MODULE(plugin)->interface;
if (final != NULL)
{
+ free(final->name);
+ free(final->desc);
+ free(final->version);
+
assert(final->required_count == 1);
free(final->required);
+ if (final->actions != NULL)
+ free(final->actions);
+
free(final);
}
@@ -1025,10 +1036,14 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename)
G_PLUGIN_MODULE(result)->filename = strdup(filename);
- result->module = module;
- result->instance = instance;
+ /**
+ * L'instance Python et l'objet GLib résultante sont un même PyGObject.
+ *
+ * Donc pas besoin de toucher au comptage des références ici, la libération
+ * se réalisera à la fin, quand l'objet GLib sera libéré.
+ */
- Py_INCREF(instance);
+ Py_DECREF(module);
return G_PLUGIN_MODULE(result);