[gjs] value: Crash harder if we don't have introspection info for an enum



commit 493270b07ad032e9a36205b83d8bdd70c033ec9c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Oct 30 18:49:14 2013 -0400

    value: Crash harder if we don't have introspection info for an enum
    
    Currently, we accidentally crash if we don't have introspection info
    for an enum, because we try to unref the NULL info. Instead of fixing
    this so that it doesn't unref, let's ensure that we do have
    introspection info for an enum.

 gi/value.cpp |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/gi/value.cpp b/gi/value.cpp
index 4f2426f..2eb9bec 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -614,15 +614,10 @@ convert_int_to_enum (JSContext *context,
 
         /* Need to distinguish between negative integers and unsigned integers */
 
-        info = g_irepository_find_by_gtype(g_irepository_get_default(),
-                                           gtype);
+        info = g_irepository_find_by_gtype(g_irepository_get_default(), gtype);
+        g_assert (info);
 
-        if (info == NULL) /* hope for the best */
-            v_double = v;
-        else
-            v_double = _gjs_enum_from_int ((GIEnumInfo *)info, v);
-
-        g_base_info_unref(info);
+        v_double = _gjs_enum_from_int ((GIEnumInfo *)info, v);
     }
 
     return JS_NewNumberValue(context, v_double, value_p);


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