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 | 598a45b7f7169b3c5ac12cc3c05580af8341dcb2 (patch) | |
tree | a6f3bbc8cb71a11ba1156c107fc1b498332e494d | |
parent | bbde321f38811c4de93825255a57c3383cf90781 (diff) | |
download | pygobject-598a45b7f7169b3c5ac12cc3c05580af8341dcb2.tar.gz pygobject-598a45b7f7169b3c5ac12cc3c05580af8341dcb2.tar.xz pygobject-598a45b7f7169b3c5ac12cc3c05580af8341dcb2.zip |
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-- | gobject/pygenum.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gobject/pygenum.c b/gobject/pygenum.c index 17888c8..5df360b 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 |