From b2b748b07ca9fa723edd3163b4d82fee42975bd6 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 13 May 2026 15:44:00 +0800 Subject: [PATCH] DisplayServer (Linux): fixes a memory leak --- src/detection/displayserver/linux/wayland/kde-output.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/detection/displayserver/linux/wayland/kde-output.c b/src/detection/displayserver/linux/wayland/kde-output.c index 43a6f373a..90d5770cd 100644 --- a/src/detection/displayserver/linux/wayland/kde-output.c +++ b/src/detection/displayserver/linux/wayland/kde-output.c @@ -205,6 +205,16 @@ const char* ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* re wldata->ffwl_proxy_destroy(output); return "Failed to roundtrip kde_output_device_v2"; } + // Destroy any mode proxies that were created during the listeners. + // wl proxies created for modes are not automatically freed by destroying + // the parent output proxy, so destroy them explicitly to avoid leaks. + FF_LIST_FOR_EACH (WaylandKdeMode, m, modes) { + if (m->pMode) { + wldata->ffwl_proxy_destroy((struct wl_proxy*) m->pMode); + m->pMode = NULL; + } + } + wldata->ffwl_proxy_destroy(output); if (display.width <= 0 || display.height <= 0 || !display.internal) {