From acf9d9de2bb3ac195adc257f4a307e447e171614 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 1 Oct 2021 12:46:44 +0200 Subject: Fix leak of properties after XkbRF_GetNamesProp Struct _XkbRF_VarDefs for XkbRF_GetNamesProp needs special cleanup logic, but it's currently missing from API: https://gitlab.freedesktop.org/xorg/lib/libxkbfile/-/issues/6 Workaround it with manual deinitialization. Pick-to: 6.2 Change-Id: I3ebe20f58199277521b31b2cd8034c92fd1f2b7f Reviewed-by: Peter Varga Reviewed-by: Michal Klocek --- src/core/ozone/ozone_platform_qt.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp index 5b42acd9f..8dbacfb2f 100644 --- a/src/core/ozone/ozone_platform_qt.cpp +++ b/src/core/ozone/ozone_platform_qt.cpp @@ -164,7 +164,17 @@ static std::string getCurrentKeyboardLayout() if (XkbGetState(dpy, XkbUseCoreKbd, &state) != 0) return std::string(); - XkbRF_VarDefsRec vdr; + XkbRF_VarDefsRec vdr {}; // zero initialize it + struct Cleanup { + XkbRF_VarDefsRec &vdr; + Cleanup(XkbRF_VarDefsRec &vdr) : vdr(vdr) { } + ~Cleanup() { + free (vdr.model); + free (vdr.layout); + free (vdr.variant); + free (vdr.options); + } + } cleanup(vdr); if (XkbRF_GetNamesProp(dpy, nullptr, &vdr) == 0) return std::string(); -- cgit v1.2.3