[gnome-software/wip/kalev/gnome-3-22: 18/96] trivial: Remove a memory leak if a plugin has an incorrect prefix
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/kalev/gnome-3-22: 18/96] trivial: Remove a memory leak if a plugin has an incorrect prefix
- Date: Tue, 7 Mar 2017 16:25:21 +0000 (UTC)
commit 017950d1cfde82e634c7fec3a3434bc888d38545
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 1a1567f..5efbbb4 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -141,21 +141,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_")) {
@@ -171,8 +160,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]