[glib] g_variant_get_child_value: Add a precondition on length



commit 39ba9c8e49a23c6f8a65e68af64ad5a52c26db08
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Fri May 27 16:03:04 2011 -0400

    g_variant_get_child_value: Add a precondition on length
    
    Ensure callers get a warning if they pass a bad length.
    
    Split into a separate commit and changed to order index before
    n_children by Colin Walters <walters verbum org>

 glib/gvariant-core.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/glib/gvariant-core.c b/glib/gvariant-core.c
index 6b27266..d2bd576 100644
--- a/glib/gvariant-core.c
+++ b/glib/gvariant-core.c
@@ -848,6 +848,8 @@ GVariant *
 g_variant_get_child_value (GVariant *value,
                            gsize     index_)
 {
+  g_return_val_if_fail (index_ < g_variant_n_children (value), NULL);
+
   if (~g_atomic_int_get (&value->state) & STATE_SERIALISED)
     {
       g_variant_lock (value);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]