diff options
author | Kirill Burtsev <kirill.burtsev@qt.io> | 2021-10-01 12:46:44 +0200 |
---|---|---|
committer | Kirill Burtsev <kirill.burtsev@qt.io> | 2021-10-05 12:28:49 +0200 |
commit | acf9d9de2bb3ac195adc257f4a307e447e171614 (patch) | |
tree | 9391cc333d5e96c354885dab9cf76b842f61863a | |
parent | b868f2893b3ba2fb02d9c7212de7e01b3f9e498a (diff) |
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 <pvarga@inf.u-szeged.hu>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r-- | src/core/ozone/ozone_platform_qt.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
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(); |