[gjs: 2/5] function: Assert the presency of function info only if we've arguments




commit b126a333fd7ece37308c339ad1c68daa9d51b64c
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Mon Sep 7 20:09:21 2020 +0200

    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.

 gi/function.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 68919a597..5814de851 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);
 }
 


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