[gjs/wip/3v1n0/toggle-queue-tests: 3/15] arg-cache: Do not mark a function returning void* as skip-all




commit ab1a4ed0cf1fa959d34e7100a30b32c1e5a62916
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Apr 29 20:24:53 2021 +0200

    arg-cache: Do not mark a function returning void* as skip-all
    
    While it's true that a void function has no return value, this is not
    true in the case it's a void pointer.
    
    Not doing this, will cause a crash at ffi level because we're passing to
    it a null return value pointer, while it's expecting to fill it with
    the returned data.
    
    Fixes: #406

 gi/arg-cache.cpp                        | 3 ++-
 installed-tests/js/testGIMarshalling.js | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index 7f1cead6..5ad5bd33 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -1258,7 +1258,8 @@ bool gjs_arg_cache_build_return(JSContext*, GjsArgumentCache* self,
 
     g_callable_info_load_return_type(callable, &self->type_info);
 
-    if (g_type_info_get_tag(&self->type_info) == GI_TYPE_TAG_VOID) {
+    if (g_type_info_get_tag(&self->type_info) == GI_TYPE_TAG_VOID &&
+        !g_type_info_is_pointer(&self->type_info)) {
         *inc_counter_out = false;
         gjs_arg_cache_set_skip_all(self);
         return true;
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js
index c8dec15c..6d506ac7 100644
--- a/installed-tests/js/testGIMarshalling.js
+++ b/installed-tests/js/testGIMarshalling.js
@@ -914,6 +914,10 @@ describe('Callback', function () {
 });
 
 describe('Raw pointers', function () {
+    it('gets an allocated return value', function () {
+        expect(GIMarshallingTests.pointer_in_return(null)).toBeFalsy();
+    });
+
     xit('can be roundtripped at least if the pointer is null', function () {
         expect(GIMarshallingTests.pointer_in_return(null)).toBeNull();
     }).pend('https://gitlab.gnome.org/GNOME/gjs/merge_requests/46');


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