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>
This commit is contained in:
Giovanni Campagna 2011-05-27 16:03:04 -04:00 committed by Colin Walters
parent e61fa51fd5
commit 39ba9c8e49

View File

@ -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);