[tracker-miners: 1/6] tests: Fix memory leaks



commit 6b9340ebbe033e48c5175608fe70b773b7d209fc
Author: Andrea Azzarone <andrea azzarone canonical com>
Date:   Mon Mar 18 18:30:36 2019 +0000

    tests: Fix memory leaks
    
    Closes: https://gitlab.gnome.org/GNOME/tracker-miners/issues/59

 tests/libtracker-extract/tracker-exif-test.c             | 2 ++
 tests/libtracker-extract/tracker-iptc-test.c             | 2 ++
 tests/libtracker-extract/tracker-utils-test.c            | 6 ++++++
 tests/libtracker-extract/tracker-xmp-test.c              | 5 +++++
 tests/libtracker-miners-common/tracker-date-time-test.c  | 6 ++++++
 tests/libtracker-miners-common/tracker-file-utils-test.c | 3 +++
 tests/libtracker-miners-common/tracker-type-utils-test.c | 2 ++
 7 files changed, 26 insertions(+)
---
diff --git a/tests/libtracker-extract/tracker-exif-test.c b/tests/libtracker-extract/tracker-exif-test.c
index b56c01176..1245bedff 100644
--- a/tests/libtracker-extract/tracker-exif-test.c
+++ b/tests/libtracker-extract/tracker-exif-test.c
@@ -66,6 +66,7 @@ test_exif_parse (void)
         g_assert_cmpstr (exif->gps_direction, ==, "12.3"); // -n -Exif:GPSImgDirection=12.3
         
         tracker_exif_free (exif);
+        g_free (blob);
 }
 
 static void
@@ -80,6 +81,7 @@ test_exif_parse_empty (void)
         exif = tracker_exif_new ((guchar *)blob, length, "test://file");
 
         tracker_exif_free (exif);
+        g_free (blob);
 }
 
 int
diff --git a/tests/libtracker-extract/tracker-iptc-test.c b/tests/libtracker-extract/tracker-iptc-test.c
index 2306c08fd..126aae0d9 100644
--- a/tests/libtracker-extract/tracker-iptc-test.c
+++ b/tests/libtracker-extract/tracker-iptc-test.c
@@ -120,6 +120,8 @@ load_iptc_blob (const gchar *filename)
                marker = marker->next;
        }
 
+        jpeg_destroy_decompress (&cinfo);
+
         g_free (uri);
         fclose (f);
 
diff --git a/tests/libtracker-extract/tracker-utils-test.c b/tests/libtracker-extract/tracker-utils-test.c
index 33cd685d8..f139b5486 100644
--- a/tests/libtracker-extract/tracker-utils-test.c
+++ b/tests/libtracker-extract/tracker-utils-test.c
@@ -213,6 +213,7 @@ test_date_to_iso8601 ()
         result = tracker_date_format_to_iso8601 ("2010:03:13 12:12:12", "%Y:%m:%d %H:%M:%S");
         g_assert (g_str_has_prefix (result, "2010-03-13T12:12:12"));
         g_assert_cmpint (strlen (result), <=, 25);
+        g_free (result);
 
         /* Pattern and string don't match */
         result = tracker_date_format_to_iso8601 ("2010:03:13 12:12", "%Y:%m:%d %H:%M:%S");
@@ -268,12 +269,17 @@ test_getline (void)
         f = fopen (TOP_SRCDIR "/tests/libtracker-extract/getline-test.txt", "r");
         g_assert_cmpint (tracker_getline (&line, &n, f), >, 0);
         g_assert_cmpstr (line, ==, "Line 1\n");
+        g_free (line);
+        line = NULL;
 
         g_assert_cmpint (tracker_getline (&line, &n, f), >, 0);
         g_assert_cmpstr (line, ==, "line 2\n");
+        g_free (line);
+        line = NULL;
 
         g_assert_cmpint (tracker_getline (&line, &n, f), >, 0);
         g_assert_cmpstr (line, ==, "line 3\n");
+        g_free (line);
 }
 
 int
diff --git a/tests/libtracker-extract/tracker-xmp-test.c b/tests/libtracker-extract/tracker-xmp-test.c
index 0cf7afcc2..25841cfbc 100644
--- a/tests/libtracker-extract/tracker-xmp-test.c
+++ b/tests/libtracker-extract/tracker-xmp-test.c
@@ -328,6 +328,11 @@ test_xmp_apply_location (void)
        g_assert_cmpstr (tracker_resource_get_first_string (address, "nco:region"), ==, data.state);
        g_assert_cmpstr (tracker_resource_get_first_string (address, "nco:locality"), ==, data.city);
        g_assert_cmpstr (tracker_resource_get_first_string (address, "nco:country"), ==, data.country);
+
+       g_free (data.address);
+       g_free (data.city);
+       g_free (data.state);
+       g_free (data.country);
 }
 
 
diff --git a/tests/libtracker-miners-common/tracker-date-time-test.c 
b/tests/libtracker-miners-common/tracker-date-time-test.c
index f7c322240..b9fe67649 100644
--- a/tests/libtracker-miners-common/tracker-date-time-test.c
+++ b/tests/libtracker-miners-common/tracker-date-time-test.c
@@ -110,6 +110,9 @@ test_string_to_date (void)
         /* More cases of string->date are tested in tracker_date_time_from_string...
          *  it is more convinient to test them there
          */
+
+    g_date_free (result);
+    g_date_free (expected);
 }
 
 static void
@@ -137,6 +140,9 @@ test_date_to_string (void)
        result = tracker_date_to_string (input);
 
        g_assert (result != NULL && strncmp (result, "2008-06-16T23:53:10Z", 19) == 0);
+
+    g_free (result);
+    g_free (original);
 }
 
 static void
diff --git a/tests/libtracker-miners-common/tracker-file-utils-test.c 
b/tests/libtracker-miners-common/tracker-file-utils-test.c
index 0b74b512a..a00cac966 100644
--- a/tests/libtracker-miners-common/tracker-file-utils-test.c
+++ b/tests/libtracker-miners-common/tracker-file-utils-test.c
@@ -168,6 +168,7 @@ test_path_evaluate_name (void)
 
        result = tracker_path_evaluate_name ("just-a-filename");
        g_assert_cmpstr (result, ==, "just-a-filename");
+       g_free (result);
 
        result = tracker_path_evaluate_name ("$HOME/all/dir/");
        expected = g_build_path (G_DIR_SEPARATOR_S, home, "/all/dir", NULL);
@@ -215,9 +216,11 @@ test_path_evaluate_name (void)
 
         result = tracker_path_evaluate_name ("$UNDEFINED/something");
         g_assert_cmpstr (result, ==, "/something");
+        g_free (result);
 
        result = tracker_path_evaluate_name (tracker_test_helpers_get_nonutf8 ());
        g_assert_cmpstr (result, ==, tracker_test_helpers_get_nonutf8 ());
+       g_free (result);
 
        g_free (home);
        g_free (pwd);
diff --git a/tests/libtracker-miners-common/tracker-type-utils-test.c 
b/tests/libtracker-miners-common/tracker-type-utils-test.c
index 31ecbec5f..03a811da7 100644
--- a/tests/libtracker-miners-common/tracker-type-utils-test.c
+++ b/tests/libtracker-miners-common/tracker-type-utils-test.c
@@ -58,6 +58,7 @@ test_string_in_string_list (void)
        g_assert_cmpint (tracker_string_in_string_list ("Audio:Title", pieces), ==, 12);
 
        g_assert_cmpint (tracker_string_in_string_list ("terms", NULL), ==, -1);
+    g_strfreev (pieces);
 }
 
 static void
@@ -143,6 +144,7 @@ test_string_to_string_list (void)
         result = tracker_string_to_string_list (input);
         g_assert_cmpint (g_strv_length (result), ==, 1);
         g_assert_cmpstr (result [0], ==, "first line");
+        g_strfreev (result);
 }
 
 static void


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