[gjs/ewlsh/fix-data-corruption] gi: Correctly hold refernces for gvariant transfer parameters
- From: Evan Welsh <ewlsh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/ewlsh/fix-data-corruption] gi: Correctly hold refernces for gvariant transfer parameters
- Date: Tue, 29 Jun 2021 08:12:42 +0000 (UTC)
commit 9b97bd97c8f9080f1f001e34250bf06f5277386d
Author: Evan Welsh <contact evanwelsh com>
Date: Tue Jun 29 01:11:29 2021 -0700
gi: Correctly hold refernces for gvariant transfer parameters
gi/boxed.cpp | 8 ++++++--
installed-tests/js/testGIMarshalling.js | 4 ++--
2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 44c2063c..7327c317 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -1024,8 +1024,12 @@ bool BoxedInstance::init_from_c_struct(JSContext* cx, void* gboxed) {
copy_boxed(gboxed);
return true;
} else if (gtype() == G_TYPE_VARIANT) {
- own_ptr(g_variant_ref_sink(static_cast<GVariant*>(gboxed)));
- debug_lifecycle("Boxed pointer created by sinking GVariant ref");
+ // Sink the reference if it is floating
+ GVariant* temp = g_variant_take_ref(static_cast<GVariant*>(gboxed));
+ // Add an additional reference which will be unref-ed
+ // in the marshaller
+ own_ptr(g_variant_ref(temp));
+ debug_lifecycle("Boxed pointer created by taking GVariant ref");
return true;
} else if (get_prototype()->can_allocate_directly()) {
copy_memory(gboxed);
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js
index c0bce490..27e05c8a 100644
--- a/installed-tests/js/testGIMarshalling.js
+++ b/installed-tests/js/testGIMarshalling.js
@@ -515,11 +515,11 @@ describe('Zero-terminated C array', function () {
});
['none', 'container', 'full'].forEach(transfer => {
- xit(`marshals as a transfer-${transfer} in and out parameter`, function () {
+ it(`marshals as a transfer-${transfer} in and out parameter`, function () {
const returnedArray =
GIMarshallingTests[`array_gvariant_${transfer}_in`](variantArray);
expect(returnedArray.map(v => v.deepUnpack())).toEqual([27, 'Hello']);
- }).pend('https://gitlab.gnome.org/GNOME/gjs/issues/269');
+ });
});
});
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]