[gjs/gnome-3-36] arg: Fix GHashTable key marshalling on 64-bit big-endian



commit b8b500440099601a62dae87dd9fde32f2e42896a
Author: Simon McVittie <smcv debian org>
Date:   Tue Apr 7 08:31:32 2020 +0100

    arg: Fix GHashTable key marshalling on 64-bit big-endian
    
    Similar to the previous commit, it is not correct to write to
    arg->v_pointer and then have _g_type_info_argument_from_hash_pointer()
    read out a different member of the GIArgument union.
    
    This particular change fixes conversion of GHashTable<int, x>
    from GLib to JavaScript, part of #309.
    
    Signed-off-by: Simon McVittie <smcv debian org>

 gi/arg.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 530bbd2d..18f8267b 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2749,8 +2749,11 @@ gjs_object_from_g_hash (JSContext             *context,
     JS::RootedString keystr(context);
 
     g_hash_table_iter_init(&iter, hash);
+    void* key_pointer;
     void* val_pointer;
-    while (g_hash_table_iter_next(&iter, &keyarg.v_pointer, &val_pointer)) {
+    while (g_hash_table_iter_next(&iter, &key_pointer, &val_pointer)) {
+        _g_type_info_argument_from_hash_pointer(key_param_info, key_pointer,
+                                                &keyarg);
         if (!gjs_value_from_g_argument(context, &keyjs,
                                        key_param_info, &keyarg,
                                        true))


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