mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-20 19:30:32 +01:00
Add test case for assert when unwinding a container.
* dbus/dbus-message-util.c: when constructing an array of structures,
it's not possible to unwind in case of an error part-way through.
This test will therefore assert.
Signed-off-by: Scott James Remnant <scott@ubuntu.com>
(cherry picked from commit 4bea3ca2b0)
This commit is contained in:
parent
0539a23c66
commit
bf2183345f
1 changed files with 29 additions and 0 deletions
|
|
@ -939,6 +939,7 @@ _dbus_message_test (const char *test_data_dir)
|
|||
unsigned char v_BYTE;
|
||||
unsigned char v2_BYTE;
|
||||
dbus_bool_t v_BOOLEAN;
|
||||
DBusMessageIter iter, array_iter, struct_iter;
|
||||
|
||||
message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
|
||||
"/org/freedesktop/TestPath",
|
||||
|
|
@ -1272,6 +1273,34 @@ _dbus_message_test (const char *test_data_dir)
|
|||
|
||||
check_memleaks ();
|
||||
|
||||
/* Check that we can abandon a container */
|
||||
message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
|
||||
"/org/freedesktop/TestPath",
|
||||
"Foo.TestInterface",
|
||||
"Method");
|
||||
|
||||
dbus_message_iter_init_append (message, &iter);
|
||||
|
||||
_dbus_assert (dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
|
||||
(DBUS_STRUCT_BEGIN_CHAR_AS_STRING
|
||||
DBUS_TYPE_STRING_AS_STRING
|
||||
DBUS_TYPE_STRING_AS_STRING
|
||||
DBUS_STRUCT_END_CHAR_AS_STRING),
|
||||
&array_iter));
|
||||
_dbus_assert (dbus_message_iter_open_container (&array_iter, DBUS_TYPE_STRUCT,
|
||||
NULL, &struct_iter));
|
||||
|
||||
s = "peaches";
|
||||
_dbus_assert (dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING,
|
||||
&s));
|
||||
|
||||
/* uh-oh, error, try and unwind */
|
||||
|
||||
_dbus_assert (dbus_message_iter_close_container (&array_iter, &struct_iter));
|
||||
_dbus_assert (dbus_message_iter_close_container (&array_iter, &iter));
|
||||
|
||||
dbus_message_unref (message);
|
||||
|
||||
/* Load all the sample messages from the message factory */
|
||||
{
|
||||
DBusMessageDataIter diter;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue