Wayland: don't leak memory

#256
This commit is contained in:
Linus Dierheimer 2022-09-24 16:34:03 +02:00
parent b6dc436e03
commit 8e856c3dd6
No known key found for this signature in database
GPG Key ID: 74FA57726CDD7B61
3 changed files with 6 additions and 5 deletions

1
run.sh
View File

@ -19,5 +19,4 @@ else
fi
cmake --build . --target fastfetch ${cmake_build_args}
export LSAN_OPTIONS=suppressions=../tests/lsan.supp
./fastfetch "$@"

View File

@ -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.

View File

@ -1 +0,0 @@
leak:*libwayland-client.so*