glib r6984 - trunk/gio



Author: pborelli
Date: Tue Jun 10 11:40:45 2008
New Revision: 6984
URL: http://svn.gnome.org/viewvc/glib?rev=6984&view=rev

Log:
2008-06-10  Paolo Borelli  <pborelli katamail com>

	* gfile.c (g_file_replace_contents): do not leak the output stream.



Modified:
   trunk/gio/ChangeLog
   trunk/gio/gfile.c

Modified: trunk/gio/gfile.c
==============================================================================
--- trunk/gio/gfile.c	(original)
+++ trunk/gio/gfile.c	Tue Jun 10 11:40:45 2008
@@ -5411,6 +5411,7 @@
   GFileOutputStream *out;
   gsize pos, remainder;
   gssize res;
+  gboolean ret;
 
   g_return_val_if_fail (G_IS_FILE (file), FALSE);
   g_return_val_if_fail (contents != NULL, FALSE);
@@ -5436,18 +5437,19 @@
     {
       /* Ignore errors on close */
       g_output_stream_close (G_OUTPUT_STREAM (out), cancellable, NULL);
-      
+      g_object_unref (out);
+
       /* error is set already */
       return FALSE;
     }
   
-  if (!g_output_stream_close (G_OUTPUT_STREAM (out), cancellable, error))
-    return FALSE;
+  ret = g_output_stream_close (G_OUTPUT_STREAM (out), cancellable, error);
+  g_object_unref (out);
 
   if (new_etag)
     *new_etag = g_file_output_stream_get_etag (out);
-  
-  return TRUE;
+
+  return ret;
 }
 
 typedef struct {



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