diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2020-09-01 20:59:27 +0200 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2020-09-01 21:30:47 +0200 |
commit | aa28329b7c62a2a751cb038b9d311ae8512ac759 (patch) | |
tree | d1d72bc88ffad4b19fede186347674cef4c0f1d4 | |
parent | 498b65ac3f0a4b00b88fda3ccd6e0e176e80d50c (diff) | |
download | gjs-aa28329b7c62a2a751cb038b9d311ae8512ac759.tar.gz |
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
-rw-r--r-- | gi/arg-cache.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp index 7f75a8b4..6e193a4b 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); |