tests: Fix various minor memory leaks in gdbus-serialization

This commit is contained in:
Philip Withnall 2015-04-21 23:55:49 +01:00
parent 41acf970ac
commit c62f7a7d68

View File

@ -511,6 +511,7 @@ get_body_signature (GVariant *value)
return ret;
}
/* If @value is floating, this assumes ownership. */
static void
check_serialization (GVariant *value,
const gchar *expected_dbus_1_output)
@ -628,6 +629,7 @@ check_serialization (GVariant *value,
}
}
g_object_unref (recovered_message);
g_free (blob);
}
g_object_unref (message);
@ -692,6 +694,7 @@ message_serialize_complex (void)
" dict_entry:\n"
" string: 'two'\n"
" string: 'black'\n");
g_variant_unref (value);
value = g_variant_parse (G_VARIANT_TYPE ("(sa{sv}as)"),
"('01234567890123456', {}, ['Something'])",
@ -703,6 +706,7 @@ message_serialize_complex (void)
"value 1: array:\n"
"value 2: array:\n"
" string: 'Something'\n");
g_variant_unref (value);
/* https://bugzilla.gnome.org/show_bug.cgi?id=621838 */
check_serialization (g_variant_new_parsed ("(@aay [], {'cwd': <'/home/davidz/Hacking/glib/gio/tests'>})"),
@ -727,6 +731,7 @@ message_serialize_complex (void)
"value 1: array:\n"
" unix-fd: (not extracted)\n"
" unix-fd: (not extracted)\n");
g_variant_unref (value);
#endif
}
@ -838,6 +843,7 @@ message_serialize_invalid (void)
g_assert (message == NULL);
dbus_free (blob);
dbus_message_unref (dbus_message);
}
}
@ -1015,6 +1021,7 @@ message_parse_empty_arrays_of_arrays (void)
" array:\n"
" array:\n"
" array:\n");
g_variant_unref (body);
body = g_variant_parse (G_VARIANT_TYPE ("(aaa{uu})"),
"([@aa{uu} [], [], []],)", NULL, NULL, &error);
@ -1024,6 +1031,7 @@ message_parse_empty_arrays_of_arrays (void)
" array:\n"
" array:\n"
" array:\n");
g_variant_unref (body);
/* Due to the same bug, g_dbus_message_new_from_blob() would fail for this
* message because it would try to read past the end of the string. Hence,
@ -1044,6 +1052,7 @@ message_parse_empty_arrays_of_arrays (void)
" struct:\n"
" array:\n"
" array:\n");
g_variant_unref (body);
}
/* ---------------------------------------------------------------------------------------------------- */
@ -1075,6 +1084,7 @@ test_double_array (void)
g_variant_new ("(@ad)", g_variant_builder_end (&builder)),
NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
g_error_free (error);
g_object_unref (conn);
}