[frogr] Fix memory leak in flicksoup: SoupBuffer with file contents was never freed!



commit 03889efc5aafbc60505e57c159bcd3ef2961ac87
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Sat Dec 21 08:24:00 2013 +0000

    Fix memory leak in flicksoup: SoupBuffer with file contents was never freed!
    
    Also, moved memory management for the contents of the file loaded to its
    right place (the finish callback for the file load operation) and create
    the SoupBuffer with SOUP_MEMORY_TEMPORARY instead of SOUP_MEMORY_TAKE.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720156

 src/flicksoup/fsp-session.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/flicksoup/fsp-session.c b/src/flicksoup/fsp-session.c
index c978780..bfe4bae 100644
--- a/src/flicksoup/fsp-session.c
+++ b/src/flicksoup/fsp-session.c
@@ -721,7 +721,7 @@ _get_soup_message_for_upload            (GFile       *file,
     }
 
   /* Append the content of the file */
-  buffer = soup_buffer_new (SOUP_MEMORY_TAKE, contents, length);
+  buffer = soup_buffer_new (SOUP_MEMORY_TEMPORARY, contents, length);
   soup_multipart_append_form_file (mpart, "photo", fileuri,
                                    mime_type, buffer);
 
@@ -734,6 +734,7 @@ _get_soup_message_for_upload            (GFile       *file,
 
   /* Free */
   soup_multipart_free (mpart);
+  soup_buffer_free (buffer);
   g_free (fileuri);
   g_free (mime_type);
 
@@ -751,7 +752,7 @@ _load_file_contents_cb                  (GObject      *object,
   GHashTable *extra_params = NULL;
   GFile *file = NULL;
   GError *error = NULL;
-  gchar *contents;
+  gchar *contents = NULL;
   gsize length;
 
   g_return_if_fail (G_IS_FILE (object));
@@ -811,6 +812,7 @@ _load_file_contents_cb                  (GObject      *object,
       error = g_error_new (FSP_ERROR, FSP_ERROR_OTHER, "Error reading file for upload");
       _build_async_result_and_complete (ard_clos, NULL, error);
     }
+  g_free (contents);
 }
 
 static void


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