[frogr] fix memory leaks (#656519)



commit 1bf0c12412172ef1738f2fce6c3ac8b61871d93b
Author: Christophe Fergeau <teuf gnome org>
Date:   Sun Aug 14 16:10:05 2011 +0200

    fix memory leaks (#656519)
    
    Fix a few memory leaks found using
    G_SLICE=always-malloc valgrind --log-file=frogr.log
    --leak-check=full --num-callers=40 frogr
    and then uploading a photo.
    
    There are still a few leaks remaining, especially in code
    interacting with libsoup
    
    https://bugzilla.gnome.org/show_bug.cgi?id=656519

 src/flicksoup/fsp-session.c |    3 +++
 src/frogr-main-view.c       |    6 ++++++
 2 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/flicksoup/fsp-session.c b/src/flicksoup/fsp-session.c
index 22afc5b..8090af6 100644
--- a/src/flicksoup/fsp-session.c
+++ b/src/flicksoup/fsp-session.c
@@ -544,6 +544,7 @@ _get_soup_message_for_upload            (GFile       *file,
                                  NULL);
   /* Check mimetype */
   mime_type = g_strdup (g_file_info_get_content_type (file_info));
+  g_object_unref (G_OBJECT (file_info));
 
   /* Init multipart container */
   mpart = soup_multipart_new (SOUP_FORM_MIME_TYPE_MULTIPART);
@@ -1103,6 +1104,8 @@ _build_async_result_and_complete        (AsyncRequestData *clos,
 
   /* Execute the callback */
   g_simple_async_result_complete_in_idle (res);
+
+  g_object_unref (G_OBJECT (res));
 }
 
 gpointer
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index e61a08f..ec947e9 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -373,6 +373,8 @@ _on_icon_view_drag_data_received (GtkWidget *widget,
       gchar *fileuri = g_strdup (fileuris_array[i]);
       if (fileuri && !g_str_equal (g_strstrip (fileuri), ""))
         fileuris_list = g_slist_append (fileuris_list, fileuri);
+      else
+        g_free (fileuri);
     }
 
   /* Load pictures */
@@ -684,6 +686,7 @@ _on_icon_view_query_tooltip (GtkWidget *icon_view,
       /* Free memory */
       gtk_tree_path_free (path);
       g_free (tooltip_str);
+      g_free (filesize);
       g_free (filesize_str);
       g_free (filesize_markup);
       g_free (datetime_markup);
@@ -783,6 +786,7 @@ _add_picture_to_ui (FrogrMainView *self, FrogrPicture *picture)
                       -1);
 
   g_object_ref (picture);
+  g_object_unref (pixbuf);
 
   /* Reorder if needed */
   if (priv->sorting_criteria != SORT_AS_LOADED || priv->sorting_reversed)
@@ -1236,6 +1240,7 @@ _update_account_menu_items (FrogrMainView *mainview)
 
           gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), value);
         }
+      g_list_free (all_items);
     }
 }
 
@@ -1455,6 +1460,7 @@ _frogr_main_view_finalize (GObject *object)
 
   gtk_widget_destroy (priv->pictures_ctxt_menu);
   gtk_widget_destroy (GTK_WIDGET (priv->window));
+  g_object_unref (G_OBJECT (priv->builder));
 
   G_OBJECT_CLASS(frogr_main_view_parent_class)->finalize (object);
 }



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