[spice-gtk v1 03/10] test-file-transfer: Don't leak SpiceFileTransferTask

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

 



The xfer-task reference given by hash table belongs to the caller so
we need to release it. Releasing on "finish" callback the same way
channel-main does but is possible to do on teardown function too.
---
 tests/file-transfer.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/file-transfer.c b/tests/file-transfer.c
index a27b9cf..bf959ac 100644
--- a/tests/file-transfer.c
+++ b/tests/file-transfer.c
@@ -78,6 +78,12 @@ transfer_xfer_task_on_finished(SpiceFileTransferTask *xfer_task,
 {
     Fixture *f = user_data;
 
+    if (xfer_task != NULL) {
+        guint32 task_id = spice_file_transfer_task_get_id(xfer_task);
+        g_hash_table_remove(f->xfer_tasks, GUINT_TO_POINTER(task_id));
+        g_object_unref(xfer_task);
+    }
+
     f->num_files_done++;
     if (f->num_files == f->num_files_done)
         g_main_loop_quit(f->loop);
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]