diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-09-27 17:47:46 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-09-28 12:12:45 +0100 |
commit | 3183d79b119d0296924602f19d9fc2a58a7bd597 (patch) | |
tree | c1969580699b0164d0408fd7f03a3b73acc391d8 | |
parent | 7fcaf6c8c6d0e6ade0e8d5460b5311b564a24d3f (diff) |
dbus_g_type_collection_get_fixed: check preconditions on the type and vtable
Previously, if it wasn't a collection or didn't have the fixed_accessor,
we'd just segfault. Not ideal.
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37793
Bug-NB: related to NB#218973
-rw-r--r-- | dbus/dbus-gtype-specialized.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/dbus/dbus-gtype-specialized.c b/dbus/dbus-gtype-specialized.c index 84efaf6..5eeb365 100644 --- a/dbus/dbus-gtype-specialized.c +++ b/dbus/dbus-gtype-specialized.c @@ -769,6 +769,7 @@ dbus_g_type_collection_get_fixed (GValue *value, guint *len_ret) { DBusGTypeSpecializedData *data; + DBusGTypeSpecializedCollectionVtable *vtable; GType gtype; dbus_g_type_specialized_init(); @@ -776,12 +777,17 @@ dbus_g_type_collection_get_fixed (GValue *value, g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), FALSE); gtype = G_VALUE_TYPE (value); + g_return_val_if_fail (dbus_g_type_is_collection (gtype), FALSE); + data = lookup_specialization_data (gtype); - g_return_val_if_fail (data != NULL, FALSE); + /* dbus_g_type_is_collection() already checked this */ + g_assert (data != NULL); - return ((DBusGTypeSpecializedCollectionVtable *) (data->klass->vtable))->fixed_accessor (gtype, - g_value_get_boxed (value), - data_ret, len_ret); + vtable = (DBusGTypeSpecializedCollectionVtable *) (data->klass->vtable); + g_return_val_if_fail (vtable->fixed_accessor != NULL, FALSE); + + return vtable->fixed_accessor (gtype, g_value_get_boxed (value), + data_ret, len_ret); } /** |