Commit 3b5c92f7 authored by Sam Thursfield's avatar Sam Thursfield

Merge branch 'fix-issue-59' into 'master'

Fix memory leaks/corruptions when running tests

Closes #59

See merge request !54
parents 1eeca0bc 429d0473
Pipeline #72314 passed with stage
in 1 minute and 36 seconds
......@@ -574,7 +574,9 @@ iterate_simple (const gchar *uri,
*/
} else if (!current_region->type && g_ascii_strcasecmp (propname, "mwg-rs:Type") == 0) {
current_region->type = g_strdup (value);
} else if (!current_region->link_class && !current_region->link_uri &&
}
else if (!current_region->link_class && !current_region->link_uri &&
strrchr (path, ']') != NULL && strrchr (path, ']') + 2 < strrchr (path, '\0') &&
g_str_has_prefix (strrchr (path, ']') + 2, "mwg-rs:Extensions")) {
current_region->link_class = g_strdup (propname);
current_region->link_uri = g_strdup (value);
......
......@@ -211,8 +211,11 @@ tracker_seccomp_init (void)
g_debug ("Loading seccomp rules.");
if (seccomp_load (ctx) >= 0)
if (seccomp_load (ctx) >= 0) {
/* Any seccomp filters loaded into the kernel are not affected. */
seccomp_release (ctx);
return TRUE;
}
out:
g_critical ("Failed to load seccomp rules.");
......
......@@ -2360,7 +2360,7 @@ process_file_cb (GObject *object,
GFileInfo *file_info;
guint64 time_;
GFile *file, *parent;
gchar *uri, *sparql_str, *time_str;
gchar *uri, *sparql_str, *sparql_update_str, *time_str;
GError *error = NULL;
gboolean is_iri;
gboolean is_directory;
......@@ -2471,9 +2471,10 @@ process_file_cb (GObject *object,
miner_files_add_rdf_types (resource, file, mime_type);
mount_point_sparql = update_mount_point_sparql (data);
sparql_update_str = tracker_resource_print_sparql_update (resource, NULL, TRACKER_OWN_GRAPH_URN),
sparql_str = g_strdup_printf ("%s %s %s",
delete_properties_sparql ? delete_properties_sparql : "",
tracker_resource_print_sparql_update (resource, NULL, TRACKER_OWN_GRAPH_URN),
sparql_update_str,
mount_point_sparql ? mount_point_sparql : "");
g_free (delete_properties_sparql);
g_free (mount_point_sparql);
......@@ -2488,6 +2489,7 @@ process_file_cb (GObject *object,
g_object_unref (file_info);
g_free (sparql_str);
g_free (uri);
g_free (sparql_update_str);
}
static gboolean
......
......@@ -128,6 +128,7 @@ process_desktop_file (TrackerResource *resource,
if (g_key_file_get_boolean (key_file, GROUP_DESKTOP_ENTRY, "Hidden", NULL)) {
g_debug ("Desktop file is hidden");
g_key_file_free (key_file);
g_free (type);
return FALSE;
}
......@@ -163,6 +164,7 @@ process_desktop_file (TrackerResource *resource,
} else {
/* Invalid type, all valid types are already listed above */
g_warning ("Unknown desktop entry type '%s'", type);
g_free (type);
g_key_file_free (key_file);
g_strfreev (cats);
g_free (lang);
......@@ -253,6 +255,7 @@ process_desktop_file (TrackerResource *resource,
g_free (name);
g_free (lang);
g_free (type);
return TRUE;
}
......
......@@ -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
......
......@@ -120,6 +120,8 @@ load_iptc_blob (const gchar *filename)
marker = marker->next;
}
jpeg_destroy_decompress (&cinfo);
g_free (uri);
fclose (f);
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment