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-14 06:57:50 +0000 |
commit | 5f6a292bc53b9adf14c0e45a7de226a56449dbca (patch) | |
tree | 5fb265089fd473b94de7ebc6bc353937ffd62707 /src/core | |
parent | 603ad5cc9806321a5a5e12ea84c58010d7930447 (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.
Change-Id: I3ebe20f58199277521b31b2cd8034c92fd1f2b7f
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit acf9d9de2bb3ac195adc257f4a307e447e171614)
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core')
-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 c547cf783..1d6fa1ed5 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(); |