[gjs] Only call g_registered_type_info_get_g_type on GIRegisteredTypeInfo.



commit 59189fc2bf0a27e19c1d8889fb9e856db477223f
Author: C. Scott Ananian <cscott litl com>
Date:   Thu Apr 30 03:49:41 2009 -0400

    Only call g_registered_type_info_get_g_type on GIRegisteredTypeInfo.
    
    We were invoking it regardless of the symbol type; this causes segfaults
    if (for example) the symbol type is GI_INFO_TYPE_CALLBACK.
---
 gi/arg.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/gi/arg.c b/gi/arg.c
index adb70b1..fd99299 100644
--- a/gi/arg.c
+++ b/gi/arg.c
@@ -440,7 +440,30 @@ gjs_value_to_g_argument(JSContext      *context,
 
             interface_type = g_base_info_get_type(interface_info);
 
-            gtype = g_registered_type_info_get_g_type((GIRegisteredTypeInfo*)interface_info);
+            switch(interface_type) {
+
+            case GI_INFO_TYPE_STRUCT:
+            case GI_INFO_TYPE_ENUM:
+            case GI_INFO_TYPE_OBJECT:
+            case GI_INFO_TYPE_INTERFACE:
+            case GI_INFO_TYPE_UNION:
+            case GI_INFO_TYPE_BOXED:
+                /* These are subtypes of GIRegisteredTypeInfo for which the
+                 * cast is safe */
+                gtype = g_registered_type_info_get_g_type
+                    ((GIRegisteredTypeInfo*)interface_info);
+                break;
+
+            case GI_INFO_TYPE_VALUE:
+                /* Special case for GValues */
+                gtype = G_TYPE_VALUE;
+                break;
+
+            default:
+                /* Everything else */
+                gtype = G_TYPE_NONE;
+                break;
+            }
 
             if (gtype != G_TYPE_NONE)
                 gjs_debug_marshal(GJS_DEBUG_GFUNCTION,



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