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

Victor Toso victortoso at redhat.com
Fri Jul 29 22:26:24 UTC 2016


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



More information about the Spice-devel mailing list