diff options
author | John Finlay <finlay@src.gnome.org> | 2004-08-15 02:23:11 +0000 |
---|---|---|
committer | John Finlay <finlay@src.gnome.org> | 2004-08-15 02:23:11 +0000 |
commit | 2f76148cc63b9eafe2917b165243cb33d0abb520 (patch) | |
tree | 90aa7828cbfe908b92a2cb365e6fae468ce78d15 | |
parent | aefea848b10fbf77cdb2958ac053b556a4b7d8f0 (diff) | |
download | pygtk-2f76148cc63b9eafe2917b165243cb33d0abb520.tar.gz |
gobject/pygenum.c (pyg_enum_repr) Match enum values to avoid segfaults
* 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.
-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 |