diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | gobject/pygenum.c | 6 |
2 files changed, 11 insertions, 1 deletions
@@ -1,3 +1,9 @@ +2004-08-14 John Finlay <finlay@moeraki.com> + + * gobject/pygenum.c (pyg_enum_repr) Match enum values to avoid + segfaults when enum minimum isn't 0 and values aren't a continuous + sequence. + Wed Aug 11 11:43:07 2004 Jonathan Blandford <jrb@redhat.com> * Makefile.am: diff --git a/gobject/pygenum.c b/gobject/pygenum.c index 17888c8b..5df360b6 100644 --- a/gobject/pygenum.c +++ b/gobject/pygenum.c @@ -53,12 +53,16 @@ pyg_enum_repr(PyGEnum *self) { GEnumClass *enum_class; char *value; + guint index; static char tmp[256]; enum_class = g_type_class_ref(self->gtype); g_assert(G_IS_ENUM_CLASS(enum_class)); - value = enum_class->values[self->parent.ob_ival].value_name; + for (index = 0; index < enum_class->n_values; index++) + if (self->parent.ob_ival == enum_class->values[index].value) + break; + value = enum_class->values[index].value_name; if (value) sprintf(tmp, "<enum %s of type %s>", value, g_type_name(self->gtype)); else |