[tracker/wip/carlosg/coverity-warnings: 7/18] tests: Plug leaks




commit 7d2897f8598672a8808382e54249f4533852b93f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Mar 20 12:47:48 2021 +0100

    tests: Plug leaks
    
    CIDs: #1501103, #1501109, #1501116

 tests/libtracker-data/tracker-service-test.c     | 4 +++-
 tests/libtracker-sparql/tracker-fd-test.c        | 5 ++++-
 tests/libtracker-sparql/tracker-statement-test.c | 4 +++-
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/tests/libtracker-data/tracker-service-test.c b/tests/libtracker-data/tracker-service-test.c
index 5fd33e3f9..b0fb49615 100644
--- a/tests/libtracker-data/tracker-service-test.c
+++ b/tests/libtracker-data/tracker-service-test.c
@@ -184,6 +184,7 @@ test_sparql_query (TestInfo      *test_info,
        gchar *results_filename;
        gchar *prefix, *test_prefix;
        GFile *ontology;
+       GThread *thread;
 
        /* initialization */
        prefix = g_build_filename (TOP_SRCDIR, "tests", "libtracker-data", NULL);
@@ -198,7 +199,7 @@ test_sparql_query (TestInfo      *test_info,
        remote = tracker_sparql_connection_new (0, NULL, ontology, NULL, &error);
        g_assert_no_error (error);
 
-       g_thread_new (NULL, thread_func, remote);
+       thread = g_thread_new (NULL, thread_func, remote);
        while (!endpoint) {
                g_usleep (100);
        }
@@ -230,6 +231,7 @@ test_sparql_query (TestInfo      *test_info,
        g_clear_object (&local);
        g_clear_object (&remote);
        g_clear_object (&endpoint);
+       g_thread_unref (thread);
 }
 
 static void
diff --git a/tests/libtracker-sparql/tracker-fd-test.c b/tests/libtracker-sparql/tracker-fd-test.c
index d65e1651a..7b49990ea 100644
--- a/tests/libtracker-sparql/tracker-fd-test.c
+++ b/tests/libtracker-sparql/tracker-fd-test.c
@@ -751,18 +751,21 @@ create_dbus_connection (GError **error)
 {
        TrackerSparqlConnection *dbus;
        GDBusConnection *dbus_conn;
+       GThread *thread;
 
        dbus_conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
        if (!dbus_conn)
                return NULL;
 
-       g_thread_new (NULL, thread_func, dbus_conn);
+       thread = g_thread_new (NULL, thread_func, dbus_conn);
 
        while (!started)
                g_usleep (100);
 
        dbus = tracker_sparql_connection_bus_new (g_dbus_connection_get_unique_name (dbus_conn),
                                                  NULL, dbus_conn, error);
+       g_thread_unref (thread);
+
        return dbus;
 }
 
diff --git a/tests/libtracker-sparql/tracker-statement-test.c 
b/tests/libtracker-sparql/tracker-statement-test.c
index b6337ea86..a66bb1281 100644
--- a/tests/libtracker-sparql/tracker-statement-test.c
+++ b/tests/libtracker-sparql/tracker-statement-test.c
@@ -244,6 +244,7 @@ create_connections (TrackerSparqlConnection **dbus,
                     GError                  **error)
 {
        StartupData data;
+       GThread *thread;
 
        data.direct = create_local_connection (NULL);
        if (!data.direct)
@@ -252,7 +253,7 @@ create_connections (TrackerSparqlConnection **dbus,
        if (!data.dbus_conn)
                return FALSE;
 
-       g_thread_new (NULL, thread_func, &data);
+       thread = g_thread_new (NULL, thread_func, &data);
 
        while (!started)
                g_usleep (100);
@@ -261,6 +262,7 @@ create_connections (TrackerSparqlConnection **dbus,
        *dbus = tracker_sparql_connection_bus_new (bus_name,
                                                   NULL, data.dbus_conn, error);
        *direct = create_local_connection (error);
+       g_thread_unref (thread);
 
        return TRUE;
 }


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