diff options
| author | John Finlay <finlay@src.gnome.org> | 2006-07-25 04:24:14 +0000 |
|---|---|---|
| committer | John Finlay <finlay@src.gnome.org> | 2006-07-25 04:24:14 +0000 |
| commit | 7ae5b1c7b2928bc4685d3493f5686f7aefa3f30b (patch) | |
| tree | 22c875d7cfd467ca3ec05aace9ca80e49388778d | |
| parent | 75ac5ae28abdac185875941a002d085abbeb3961 (diff) | |
Avoid segfault when g_flags_get_first_value returns NULL.
* gobject/pygflags.c (pyg_flags_get_first_value_name)
(pyg_flags_get_first_value_nick): Avoid segfault when
g_flags_get_first_value returns NULL.
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | gobject/pygflags.c | 15 |
2 files changed, 18 insertions, 3 deletions
@@ -1,3 +1,9 @@ +2006-07-24 John Finlay <finlay@moeraki.com> + + * gobject/pygflags.c (pyg_flags_get_first_value_name) + (pyg_flags_get_first_value_nick): Avoid segfault when + g_flags_get_first_value returns NULL. + 2006-07-20 John Finlay <finlay@moeraki.com> * docs/Makefile.am: Make version.xml dependent on config.h diff --git a/gobject/pygflags.c b/gobject/pygflags.c index 2fcfa10..dc4b03c 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -323,8 +323,12 @@ pyg_flags_get_first_value_name(PyGFlags *self, void *closure) flags_class = g_type_class_ref(self->gtype); g_assert(G_IS_FLAGS_CLASS(flags_class)); flags_value = g_flags_get_first_value(flags_class, self->parent.ob_ival); - retval = PyString_FromString(flags_value->value_name); - + if (flags_value) + retval = PyString_FromString(flags_value->value_name); + else { + retval = Py_None; + PY_INCREF(Py_None); + } g_type_class_unref(flags_class); return retval; @@ -341,7 +345,12 @@ pyg_flags_get_first_value_nick(PyGFlags *self, void *closure) g_assert(G_IS_FLAGS_CLASS(flags_class)); flags_value = g_flags_get_first_value(flags_class, self->parent.ob_ival); - retval = PyString_FromString(flags_value->value_nick); + if (flags_value) + retval = PyString_FromString(flags_value->value_nick); + else { + retval = Py_None; + PY_INCREF(Py_None); + } g_type_class_unref(flags_class); return retval; |
