[gjs] Fix gjs_value_to_g_value_internal() for uninitialized enum types



commit 8394a902efda8027b1c56a2780ec06c71581ca01
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jul 26 02:28:10 2013 +0200

    Fix gjs_value_to_g_value_internal() for uninitialized enum types
    
    g_type_class_peek() will fail if the type's class has never been
    referenced before (and we'll fail with an unhelpful error message).
    So use g_type_class_ref() instead, which will intialize the class
    structure if necessary.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704902

 gi/value.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/gi/value.c b/gi/value.c
index cc3638f..2cfec25 100644
--- a/gi/value.c
+++ b/gi/value.c
@@ -469,10 +469,12 @@ gjs_value_to_g_value_internal(JSContext    *context,
 
         if (gjs_value_to_int64 (context, value, &value_int64)) {
             GEnumValue *v;
+            gpointer gtype_class = g_type_class_ref(gtype);
 
             /* See arg.c:_gjs_enum_to_int() */
-            v = g_enum_get_value(G_ENUM_CLASS(g_type_class_peek(gtype)),
+            v = g_enum_get_value(G_ENUM_CLASS(gtype_class),
                                  (int)value_int64);
+            g_type_class_unref(gtype_class);
             if (v == NULL) {
                 gjs_throw(context,
                           "%d is not a valid value for enumeration %s",


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