tests: Fix leak when checking for du binary

g_find_program_in_path() returns a pointer, not a boolean.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2018-06-27 09:57:37 +01:00
parent 93b519b104
commit f7bd41fdaa

View File

@ -913,6 +913,13 @@ get_size_from_du (const gchar *path, guint64 *size)
gchar *result;
gchar *endptr;
GError *error = NULL;
gchar *du_path = NULL;
/* If we cant find du, dont try and run the test. */
du_path = g_find_program_in_path ("du");
if (du_path == NULL)
return FALSE;
g_free (du_path);
du = g_subprocess_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE,
&error,
@ -950,7 +957,7 @@ test_measure (void)
path = g_test_build_filename (G_TEST_DIST, "desktop-files", NULL);
file = g_file_new_for_path (path);
if (!g_find_program_in_path ("du") || !get_size_from_du (path, &size))
if (!get_size_from_du (path, &size))
{
g_test_message ("du not found or fail to run, skipping byte measurement");
size = 0;
@ -1052,8 +1059,7 @@ test_measure_async (void)
path = g_test_build_filename (G_TEST_DIST, "desktop-files", NULL);
file = g_file_new_for_path (path);
if (!g_find_program_in_path ("du") ||
!get_size_from_du (path, &data->expected_bytes))
if (!get_size_from_du (path, &data->expected_bytes))
{
g_test_message ("du not found or fail to run, skipping byte measurement");
data->expected_bytes = 0;