[gthumb] fixed some memory leaks



commit 7138f32ee2f580299416219a5b0e2fba161b76d7
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Dec 22 12:58:05 2014 +0100

    fixed some memory leaks

 extensions/bookmarks/callbacks.c |    3 ++-
 gthumb/gth-file-properties.c     |    4 +++-
 gthumb/gth-file-source-vfs.c     |   12 ++++++++----
 gthumb/gth-main-default-types.c  |    2 ++
 gthumb/gth-menu-manager.c        |    2 +-
 gthumb/gth-thumb-loader.c        |    1 +
 gthumb/gth-window.c              |    1 +
 7 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/extensions/bookmarks/callbacks.c b/extensions/bookmarks/callbacks.c
index 857f561..2e164d7 100644
--- a/extensions/bookmarks/callbacks.c
+++ b/extensions/bookmarks/callbacks.c
@@ -125,6 +125,7 @@ update_system_bookmark_list_from_content (GthBrowser *browser,
                g_menu_item_set_action_and_target (item, "win.go-to-location", "s", uri);
                g_menu_append_item (data->system_bookmarks_menu, item);
 
+               g_object_unref (item);
                g_free (name);
                g_object_unref (file);
                g_strfreev (line);
@@ -242,7 +243,7 @@ _gth_browser_update_bookmark_list (GthBrowser *browser)
                g_menu_item_set_action_and_target (item, "win.go-to-location", "s", uris[i]);
                g_menu_append_item (data->bookmarks_menu, item);
 
-               _g_object_unref (item);
+               g_object_unref (item);
                g_free (name);
                g_object_unref (file);
        }
diff --git a/gthumb/gth-file-properties.c b/gthumb/gth-file-properties.c
index 872b410..f049d8a 100644
--- a/gthumb/gth-file-properties.c
+++ b/gthumb/gth-file-properties.c
@@ -149,8 +149,10 @@ gth_file_properties_real_set_file (GthPropertyView *base,
                        continue;
 
                value = gth_file_data_get_attribute_as_string (file_data, info->id);
-               if ((value == NULL) || (*value == '\0'))
+               if ((value == NULL) || (*value == '\0')) {
+                       g_free (value);
                        continue;
+               }
 
                if (info->id != NULL) {
                        if (g_str_has_prefix (info->id, "Exif")) {
diff --git a/gthumb/gth-file-source-vfs.c b/gthumb/gth-file-source-vfs.c
index 508e0bb..9c64aa5 100644
--- a/gthumb/gth-file-source-vfs.c
+++ b/gthumb/gth-file-source-vfs.c
@@ -111,9 +111,10 @@ gth_file_source_vfs_add_uri (GList         *list,
 static GList *
 gth_file_source_vfs_get_entry_points (GthFileSource *file_source)
 {
-       GList *list;
-       GList *mounts;
-       GList *scan;
+       GList          *list;
+       GVolumeMonitor *monitor;
+       GList          *mounts;
+       GList          *scan;
 
        list = NULL;
 
@@ -123,7 +124,8 @@ gth_file_source_vfs_get_entry_points (GthFileSource *file_source)
        list = gth_file_source_vfs_add_special_dir (list, file_source, G_USER_DIRECTORY_DOWNLOAD);
        list = gth_file_source_vfs_add_uri (list, file_source, "file:///");
 
-       mounts = g_volume_monitor_get_mounts (g_volume_monitor_get ());
+       monitor = g_volume_monitor_get ();
+       mounts = g_volume_monitor_get_mounts (monitor);
        for (scan = mounts; scan; scan = scan->next) {
                GMount    *mount = scan->data;
                GIcon     *icon;
@@ -170,6 +172,7 @@ gth_file_source_vfs_get_entry_points (GthFileSource *file_source)
        }
 
        _g_object_list_unref (mounts);
+       g_object_unref (monitor);
 
        return list;
 }
@@ -219,6 +222,7 @@ gth_file_source_vfs_get_file_info (GthFileSource *file_source,
        else if (g_strcmp0 (uri, get_home_uri ()) == 0)
                g_file_info_set_display_name (file_info, _("Home Folder"));
 
+       g_free (uri);
        g_object_unref (gio_file);
 
        return file_info;
diff --git a/gthumb/gth-main-default-types.c b/gthumb/gth-main-default-types.c
index 19d03b2..f481f8a 100644
--- a/gthumb/gth-main-default-types.c
+++ b/gthumb/gth-main-default-types.c
@@ -55,6 +55,8 @@ gth_main_register_default_file_loader (void)
 
                g_strfreev (mime_types);
        }
+
+       g_slist_free (formats);
 }
 
 
diff --git a/gthumb/gth-menu-manager.c b/gthumb/gth-menu-manager.c
index 516ef1f..f14ce96 100644
--- a/gthumb/gth-menu-manager.c
+++ b/gthumb/gth-menu-manager.c
@@ -193,7 +193,7 @@ gth_menu_manager_append_entries (GthMenuManager     *menu_manager,
        GList *items;
        int    i;
 
-       g_return_if_fail (menu_manager != NULL);
+       g_return_val_if_fail (menu_manager != NULL, 0);
 
        merge_id = gth_menu_manager_new_merge_id (menu_manager);
        items = NULL;
diff --git a/gthumb/gth-thumb-loader.c b/gthumb/gth-thumb-loader.c
index 36f5aa9..7cb732b 100644
--- a/gthumb/gth-thumb-loader.c
+++ b/gthumb/gth-thumb-loader.c
@@ -511,6 +511,7 @@ is_a_cache_file (const char *uri)
 
        g_free (cache_dir_1);
        g_free (cache_dir_2);
+       g_free (filename);
 
        return result;
 }
diff --git a/gthumb/gth-window.c b/gthumb/gth-window.c
index b4aa11e..b4ade2f 100644
--- a/gthumb/gth-window.c
+++ b/gthumb/gth-window.c
@@ -257,6 +257,7 @@ gth_window_realize (GtkWidget *widget)
                                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 
        g_object_unref (css_provider);
+       g_bytes_unref (bytes);
 }
 
 


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