[pygobject] Test results of g_base_info_get_name for NULL



commit 61663928259f6f48c11f6e43334a62dd2b3eb8e6
Author: Simon Feltman <sfeltman src gnome org>
Date:   Thu Apr 25 05:27:35 2013 -0700

    Test results of g_base_info_get_name for NULL
    
    Block against potential NULL result when generating type hint with
    _g_arg_get_pytype_hint.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=698829

 gi/pygi-info.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 097f439..1229d78 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -431,11 +431,19 @@ _g_arg_get_pytype_hint (PyGIBaseInfo *self)
     } else {
        Py_DecRef(py_type);
        if (type_tag == GI_TYPE_TAG_INTERFACE) {
+           const char *info_name;
+           PyObject *py_string;
            GIBaseInfo *iface = g_type_info_get_interface(&type_info);
+
+           info_name = g_base_info_get_name (iface);
+           if (info_name == NULL) {
+               g_base_info_unref (iface);
+               return PYGLIB_PyUnicode_FromString(g_type_tag_to_string(type_tag));
+           }
+
            gchar *name = g_strdup_printf("%s.%s",
                    g_base_info_get_namespace(iface),
-                   g_base_info_get_name (iface));
-        PyObject *py_string;
+                   info_name);
            g_base_info_unref(iface);
            py_string = PYGLIB_PyUnicode_FromString(name);
            g_free(name);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]