[gjs: 3/4] byteArray: Require GLib-2.0 when looking up GBytes info



commit aab5c8e072fa0cf1c05866bd7eb5af2b98abbd87
Author: Philip Chimento <philip chimento gmail com>
Date:   Mon Nov 12 19:33:22 2018 -0500

    byteArray: Require GLib-2.0 when looking up GBytes info
    
    This caused yet another crash, though it was less likely to happen. It
    could be triggered by using the ByteArray.toGBytes() method without
    first having imported GLib.
    
    Closes #219.

 gjs/byteArray.cpp | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index cf3ae255..05b58cd2 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -179,6 +179,9 @@ to_gbytes_func(JSContext *context,
     }
 
     GBytes* bytes = gjs_byte_array_get_bytes(byte_array);
+
+    g_irepository_require(nullptr, "GLib", "2.0", GIRepositoryLoadFlags(0),
+                          nullptr);
     gbytes_info = g_irepository_find_by_gtype(NULL, G_TYPE_BYTES);
     ret_bytes_obj = gjs_boxed_from_c_struct(context, (GIStructInfo*)gbytes_info,
                                             bytes, GJS_BOXED_CREATION_NONE);


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