summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2020-09-07 20:09:21 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2020-09-10 01:36:47 +0200
commitb126a333fd7ece37308c339ad1c68daa9d51b64c (patch)
treed1baa2fe0b78979ea25349f764ee3a03f0a988e1
parent072444c69ffe83993ca351a5b7d9752ba5694086 (diff)
downloadgjs-b126a333fd7ece37308c339ad1c68daa9d51b64c.tar.gz
function: Assert the presency of function info only if we've arguments
In case the function initialization fails for some reason, we only need the info function to be set in case we have defined arguments, otherwise we might have just failed at the early stages of the cache-init function and nor the GI info or the arguments are set.
-rw-r--r--gi/function.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/gi/function.cpp b/gi/function.cpp
index 68919a59..5814de85 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1060,9 +1060,10 @@ GJS_NATIVE_CONSTRUCTOR_DEFINE_ABSTRACT(function)
static void
uninit_cached_function_data (Function *function)
{
- g_assert(function->info && "Don't know how to free cache without GI info");
-
if (function->arguments) {
+ g_assert(function->info &&
+ "Don't know how to free cache without GI info");
+
// Careful! function->arguments is offset by one or two elements inside
// the allocated space, so we have to free index -1 or -2.
int start_index = g_callable_info_is_method(function->info) ? -2 : -1;
@@ -1084,8 +1085,7 @@ uninit_cached_function_data (Function *function)
function->arguments = nullptr;
}
- g_base_info_unref(function->info);
-
+ g_clear_pointer(&function->info, g_base_info_unref);
g_function_invoker_destroy(&function->invoker);
}