[glib] g_variant_get_child(): flatten-first logic on '&'
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] g_variant_get_child(): flatten-first logic on '&'
- Date: Tue, 29 Sep 2015 14:17:53 +0000 (UTC)
commit 56b164a19566a63dda23d48a93b91875d89c9fde
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Sep 21 16:54:49 2015 -0400
g_variant_get_child(): flatten-first logic on '&'
Copy the flatten-first logic from g_variant_get(), and for the same
reason: if the user is requesting a direct pointer access to a
tree-based child inside of argument to this function then that child
could disappear later.
Forcing serialisation means that the pointer will remain valid as long
as the passed-in instance exists, which is the usual expectation with
GVariant API.
https://bugzilla.gnome.org/show_bug.cgi?id=755374
glib/gvariant.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/glib/gvariant.c b/glib/gvariant.c
index a9c34d4..85bb1ca 100644
--- a/glib/gvariant.c
+++ b/glib/gvariant.c
@@ -5446,6 +5446,10 @@ g_variant_get_child (GVariant *value,
GVariant *child;
va_list ap;
+ /* if any direct-pointer-access formats are in use, flatten first */
+ if (strchr (format_string, '&'))
+ g_variant_get_data (value);
+
child = g_variant_get_child_value (value, index_);
g_return_if_fail (valid_format_string (format_string, TRUE, child));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]