From 8e856c3dd6dd74c9a7ffcc8004c01de154b4552a Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Sat, 24 Sep 2022 16:34:03 +0200 Subject: [PATCH] Wayland: don't leak memory #256 --- run.sh | 1 - src/detection/displayserver/linux/wayland.c | 9 ++++++--- tests/lsan.supp | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 tests/lsan.supp diff --git a/run.sh b/run.sh index fa1833b0e..aebcfc9d9 100755 --- a/run.sh +++ b/run.sh @@ -19,5 +19,4 @@ else fi cmake --build . --target fastfetch ${cmake_build_args} -export LSAN_OPTIONS=suppressions=../tests/lsan.supp ./fastfetch "$@" diff --git a/src/detection/displayserver/linux/wayland.c b/src/detection/displayserver/linux/wayland.c index 3aa21e226..03d3f907f 100644 --- a/src/detection/displayserver/linux/wayland.c +++ b/src/detection/displayserver/linux/wayland.c @@ -17,6 +17,7 @@ typedef struct WaylandData FFlist* results; FF_LIBRARY_SYMBOL(wl_proxy_marshal_constructor_versioned) FF_LIBRARY_SYMBOL(wl_proxy_add_listener) + FF_LIBRARY_SYMBOL(wl_proxy_destroy) const struct wl_interface* ffwl_output_interface; } WaylandData; @@ -50,10 +51,10 @@ static void stubListener(void* data, ...) static void waylandOutputModeListener(void* data, struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) { - FF_UNUSED(output); - WaylandData* wldata = data; + wldata->ffwl_proxy_destroy((struct wl_proxy*) output); + if(!(flags & WL_OUTPUT_MODE_CURRENT) || width <= 0 || height <= 0) return; @@ -117,6 +118,7 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_marshal_constructor_versioned, false) FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_add_listener, false) + FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_destroy, false) FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_output_interface, false) struct wl_display* display = ffwl_display_connect(NULL); @@ -147,7 +149,8 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result) ffwl_display_dispatch(display); ffwl_display_roundtrip(display); - ffwl_display_disconnect(display); //This will also destroy our wl_registry and wl_output proxies + data.ffwl_proxy_destroy(registry); + ffwl_display_disconnect(display); dlclose(wayland); //We successfully connected to wayland and detected the resolution. diff --git a/tests/lsan.supp b/tests/lsan.supp deleted file mode 100644 index 12db0d090..000000000 --- a/tests/lsan.supp +++ /dev/null @@ -1 +0,0 @@ -leak:*libwayland-client.so*