[gjs: 1/2] arg-cache: Don't assume an interface type on caller allocates
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/2] arg-cache: Don't assume an interface type on caller allocates
- Date: Sat, 5 Sep 2020 18:04:43 +0000 (UTC)
commit aa28329b7c62a2a751cb038b9d311ae8512ac759
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Tue Sep 1 20:59:27 2020 +0200
arg-cache: Don't assume an interface type on caller allocates
When we get an out parameter with caller-allocates flag we assume that
it's an interface, but this may not be the case like for array out
parameters.
As per this, verify that the type tag matches the interface even when
we've a caller allocates argument.
Closes: https://gitlab.gnome.org/GNOME/gjs/-/issues/344
gi/arg-cache.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index 7f75a8b4d..6e193a4b4 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -1575,7 +1575,9 @@ bool gjs_arg_cache_build_arg(JSContext* cx, GjsArgumentCache* self,
self->skip_in = true;
*inc_counter_out = true;
- if (direction == GI_DIRECTION_OUT && g_arg_info_is_caller_allocates(arg)) {
+ GITypeTag type_tag = g_type_info_get_tag(&self->type_info);
+ if (direction == GI_DIRECTION_OUT && type_tag == GI_TYPE_TAG_INTERFACE &&
+ g_arg_info_is_caller_allocates(arg)) {
GjsAutoBaseInfo interface_info =
g_type_info_get_interface(&self->type_info);
g_assert(interface_info);
@@ -1601,7 +1603,6 @@ bool gjs_arg_cache_build_arg(JSContext* cx, GjsArgumentCache* self,
return true;
}
- GITypeTag type_tag = g_type_info_get_tag(&self->type_info);
if (type_tag == GI_TYPE_TAG_INTERFACE) {
GjsAutoBaseInfo interface_info =
g_type_info_get_interface(&self->type_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]