diff options
author | Simon McVittie <smcv@collabora.com> | 2021-01-28 21:24:50 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2021-01-28 21:39:23 +0000 |
commit | de87bcf7ff2bd1e7998ac35ad4cd727485ca14c7 (patch) | |
tree | 58d2cccde34c96e1aaf8f3a9880c7beeb429959c | |
parent | fdc192f4601cb30b382e14f1a37722271384826e (diff) | |
download | glib-de87bcf7ff2bd1e7998ac35ad4cd727485ca14c7.tar.gz |
gdbus-serialization: Don't leak string containing first serializationwip/smcv/gdbus-test-leak
We format the message into a string twice, once for each byte-order,
but only return the one corresponding to the last byte-order to the
caller. This means we need to free the first one.
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | gio/tests/gdbus-serialization.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c index 2ef70b11e..b95244c9a 100644 --- a/gio/tests/gdbus-serialization.c +++ b/gio/tests/gdbus-serialization.c @@ -524,6 +524,7 @@ get_and_check_serialization (GVariant *value) GDBusMessage *recovered_message; GError *error; DBusError dbus_error; + gchar *last_serialization = NULL; gchar *s = NULL; guint n; @@ -617,11 +618,19 @@ get_and_check_serialization (GVariant *value) } g_object_unref (recovered_message); g_free (blob); + + if (last_serialization != NULL) + { + g_assert_cmpstr (last_serialization, ==, s); + g_free (last_serialization); + } + + last_serialization = g_steal_pointer (&s); } g_object_unref (message); - return g_steal_pointer (&s); + return g_steal_pointer (&last_serialization); } /* If @value is floating, this assumes ownership. */ |