qulogic/gplugin

Merged in feature/fix-valgrind (pull request #11)
develop
2019-02-01, Gary Kramlich
f4b46063e850
Merged in feature/fix-valgrind (pull request #11)

Fix valgrind errors

Approved-by: Gary Kramlich
--- a/gplugin/gplugin-manager.c Mon Jan 28 00:48:09 2019 +0000
+++ b/gplugin/gplugin-manager.c Fri Feb 01 02:23:51 2019 +0000
@@ -1228,8 +1228,7 @@
* Gets the list of paths which will be search for plugins.
*
* Return value: (element-type utf8) (transfer none): list of paths which will
- * be searched for plugins. free the list with g_list_free when
- * done.
+ * be searched for plugins.
*/
GList *
gplugin_manager_get_paths(void) {
--- a/gplugin/gplugin-native-loader.c Mon Jan 28 00:48:09 2019 +0000
+++ b/gplugin/gplugin-native-loader.c Fri Feb 01 02:23:51 2019 +0000
@@ -107,21 +107,27 @@
GPluginPluginInfo *info = NULL;
*module = gplugin_native_loader_open(filename, flags, error);
- if((*module == NULL) || (error && *error))
+ if (*module == NULL) {
return NULL;
+ } else if (error && *error) {
+ g_module_close(*module);
+ *module = NULL;
+ return NULL;
+ }
*query = gplugin_native_loader_lookup_symbol(*module, GPLUGIN_QUERY_SYMBOL,
error);
if((*query == NULL) || (error && *error)) {
g_module_close(*module);
+ *module = NULL;
return NULL;
}
info = ((GPluginNativePluginQueryFunc)(*query))(error);
if(error && *error) {
g_module_close(*module);
-
+ *module = NULL;
return NULL;
}
@@ -143,9 +149,6 @@
info = gplugin_native_loader_open_and_query(filename, &module, 0, &query,
error);
if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
- if(module)
- g_module_close(module);
-
if (error && *error == NULL) {
g_set_error_literal(error, GPLUGIN_DOMAIN, 0,
_("the query function did not return a "
@@ -163,8 +166,6 @@
G_MODULE_BIND_LOCAL,
&query, error);
if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
- g_module_close(module);
-
if (error && *error == NULL) {
g_set_error_literal(error, GPLUGIN_DOMAIN, 0,
_("the query function did not return a "
--- a/gplugin/tests/dynamic-type/dynamic-type-user.c Mon Jan 28 00:48:09 2019 +0000
+++ b/gplugin/tests/dynamic-type/dynamic-type-user.c Fri Feb 01 02:23:51 2019 +0000
@@ -51,10 +51,14 @@
}
G_MODULE_EXPORT gboolean
-gplugin_unload(G_GNUC_UNUSED GPluginNativePlugin *plugin, GError **error) {
+gplugin_unload(G_GNUC_UNUSED GPluginNativePlugin *plugin, GError **error)
+{
+ gpointer weak_test_object = test_object;
+ g_object_add_weak_pointer(G_OBJECT(test_object), &weak_test_object);
+
g_object_unref(test_object);
- if (DYNAMIC_IS_TEST(test_object)) {
+ if (DYNAMIC_IS_TEST(weak_test_object)) {
g_set_error(error, GPLUGIN_DOMAIN, 0,
"test_object is still valid");
return FALSE;
--- a/gplugin/tests/test-plugin-manager-paths.c Mon Jan 28 00:48:09 2019 +0000
+++ b/gplugin/tests/test-plugin-manager-paths.c Fri Feb 01 02:23:51 2019 +0000
@@ -106,7 +106,6 @@
for(l = paths; l; l = l->next) {
g_hash_table_remove(req, l->data);
}
- g_list_free(paths);
size = g_hash_table_size(req);
@@ -142,7 +141,6 @@
paths = gplugin_manager_get_paths();
for(l = paths; l != NULL; l = l->next)
g_hash_table_remove(req, l->data);
- g_list_free(paths);
/* now check the hash table size, if it's > 0 then an expected path wasn't
* added.