[gnome-software] trivial: Remove a memory leak if a plugin has an incorrect prefix
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Remove a memory leak if a plugin has an incorrect prefix
- Date: Sun, 27 Nov 2016 19:14:17 +0000 (UTC)
commit 121511a32927bf1bb2d78ec61780c5c66060a243
Author: Richard Hughes <richard hughsie com>
Date: Sat Nov 26 09:34:35 2016 +0000
trivial: Remove a memory leak if a plugin has an incorrect prefix
src/gs-plugin.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index cacfbec..7d67a04 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -144,21 +144,10 @@ gs_plugin_status_to_string (GsPluginStatus status)
GsPlugin *
gs_plugin_create (const gchar *filename, GError **error)
{
- GModule *module;
GsPlugin *plugin = NULL;
GsPluginPrivate *priv;
g_autofree gchar *basename = NULL;
- module = g_module_open (filename, 0);
- if (module == NULL) {
- g_set_error (error,
- GS_PLUGIN_ERROR,
- GS_PLUGIN_ERROR_FAILED,
- "failed to open plugin %s: %s",
- filename, g_module_error ());
- return NULL;
- }
-
/* get the plugin name from the basename */
basename = g_path_get_basename (filename);
if (!g_str_has_prefix (basename, "libgs_plugin_")) {
@@ -174,8 +163,16 @@ gs_plugin_create (const gchar *filename, GError **error)
/* create new plugin */
plugin = gs_plugin_new ();
priv = gs_plugin_get_instance_private (plugin);
- priv->module = module;
priv->name = g_strdup (basename + 13);
+ priv->module = g_module_open (filename, 0);
+ if (priv->module == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
+ "failed to open plugin %s: %s",
+ filename, g_module_error ());
+ return NULL;
+ }
return plugin;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]