[gvfs] ftp: Fix refcounting of addresses when connecting



commit 00f441ca8a8786eb755c07b73076e3d5c9bd60c6
Author: Benjamin Otte <otte redhat com>
Date:   Tue Dec 7 12:23:54 2010 +0100

    ftp: Fix refcounting of addresses when connecting
    
    In error cases, we would get the refcounting wrong, which would lead to
    a warning when finalizing the backend, because we carried around an
    invalid pointer to an unreffed address for the whole time.

 daemon/gvfsbackendftp.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index ffd543d..b4e1b2d 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -380,6 +380,7 @@ do_mount (GVfsBackend *backend,
     }
 
   addr = G_NETWORK_ADDRESS (ftp->addr);
+  g_object_ref (addr);
   port = g_network_address_get_port (addr);
   username = NULL;
   password = NULL;
@@ -514,6 +515,7 @@ try_login:
    */
   if (!g_vfs_ftp_task_is_in_error (&task))
     {
+      g_object_unref (ftp->addr);
       ftp->addr = G_SOCKET_CONNECTABLE (g_vfs_ftp_connection_get_address (task.conn, &task.error));
       if (ftp->addr == NULL)
         {



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