From d81cad5ec57edb38f23b358c83e598c1609029a2 Mon Sep 17 00:00:00 2001 From: Cimbali Date: Mon, 1 Nov 2021 19:31:58 +0100 Subject: Avoid leaking memory from FFI closure if no segfault risk --- girepository/girffi.c | 3 +++ meson.build | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/girepository/girffi.c b/girepository/girffi.c index 85165132..4cf139d0 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -494,4 +494,7 @@ g_callable_info_prepare_closure (GICallableInfo *callable_info, void g_callable_info_free_closure (GICallableInfo *callable_info, ffi_closure *closure) { g_warning ("g_callable_info_free_closure is deprecated and leaks memory\n"); +#ifdef LEGACY_GIRFFI_FREE + g_callable_info_destroy_closure(callable_info, closure); +#endif } diff --git a/meson.build b/meson.build index 65aa4b06..fc503b54 100644 --- a/meson.build +++ b/meson.build @@ -8,6 +8,7 @@ project('gobject-introspection', 'c', ) host_system = host_machine.system() +host_arch = host_machine.cpu_family() gi_versions = meson.project_version().split('.') build_root = meson.current_build_dir() source_root = meson.current_source_dir() @@ -122,10 +123,6 @@ else gi_hidden_visibility_cflags += '-fvisibility=hidden' endif -configure_file( - configuration: config, - output: 'config.h' -) # FIXME: Always bumped to match our version #glib_version = '>=2.@0@.@1@'.format(gi_versions[1], gi_versions[2]) @@ -155,6 +152,15 @@ endif libffi_dep = dependency('libffi', fallback : ['libffi', 'ffi_dep']) +if host_system == 'darwin' and host_arch == 'aarch64' or host_system == 'linux' and libffi_dep.version().version_compare('< 3.4') + config.set('LEGACY_GIRFFI_FREE', 1) +endif + +configure_file( + configuration: config, + output: 'config.h' +) + # python headers cc.check_header('Python.h', dependencies: [python.dependency()], required: true) -- cgit v1.2.1