[gjs: 5/6] function: Free partially allocated cached function data



commit d1d7dafc06702a9d471a1fee7918a2be0e072b02
Author: Philip Chimento <philip endlessm com>
Date:   Wed Jul 31 15:36:34 2019 -0700

    function: Free partially allocated cached function data
    
    If init_cached_function_data() returns with an error, then the caller is
    not expected to call uninit_cached_function_data(). However, it could
    happen in two places that some allocation had already been done before
    returning with an error; in that case, free the allocated memory.

 gi/function.cpp | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index ce04027f..19b083f7 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1702,6 +1702,7 @@ init_cached_function_data (JSContext      *context,
                                   g_base_info_get_namespace( (GIBaseInfo*) info),
                                   g_base_info_get_name( (GIBaseInfo*) info));
                         g_base_info_unref(interface_info);
+                        g_free(function->param_types);
                         return false;
                     }
                 }
@@ -1719,6 +1720,7 @@ init_cached_function_data (JSContext      *context,
                         gjs_throw(context, "Function %s.%s has an array with different-direction length arg, 
not supported",
                                   g_base_info_get_namespace( (GIBaseInfo*) info),
                                   g_base_info_get_name( (GIBaseInfo*) info));
+                        g_free(function->param_types);
                         return false;
                     }
 


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