diff options
author | Cimbali <me@cimba.li> | 2021-11-01 19:31:58 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2021-11-23 23:04:26 +0000 |
commit | d81cad5ec57edb38f23b358c83e598c1609029a2 (patch) | |
tree | abb72b660edd3cc8b34f270111278757b8402184 | |
parent | 55a18f528e490f17c7fd5d790cca6075bb375c51 (diff) | |
download | gobject-introspection-d81cad5ec57edb38f23b358c83e598c1609029a2.tar.gz |
Avoid leaking memory from FFI closure if no segfault risk
-rw-r--r-- | girepository/girffi.c | 3 | ||||
-rw-r--r-- | 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) |