diff options
author | Alexander Volkov <avolkov@astralinux.ru> | 2020-11-16 00:50:35 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-11-18 15:42:20 +0000 |
commit | a904254e0b710b05d099b273c5c723cf619d7471 (patch) | |
tree | cf84277692ff7813a05931ffc1fd341a720bac36 | |
parent | d81e16005522d00ba789021f0895dd66d9972d2f (diff) |
xcb: Avoid use-after-free in QXcbConnection::initializeScreens()
Extend the scope of the resources variable to avoid its
destruction while it's still in use.
Fixes: QTBUG-88512
Change-Id: I3298aabc871ff455bd1203ec276e7600d3e151ef
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 86b8c5c3f32c245795e9eab2a74e4b6982e5a496)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection_screens.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp index 4e631beb25..9eb365597b 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_screens.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_screens.cpp @@ -290,6 +290,8 @@ void QXcbConnection::initializeScreens() // RRGetScreenResources in this case. auto resources_current = Q_XCB_REPLY(xcb_randr_get_screen_resources_current, xcb_connection(), xcbScreen->root); + decltype(Q_XCB_REPLY(xcb_randr_get_screen_resources, + xcb_connection(), xcbScreen->root)) resources; if (!resources_current) { qWarning("failed to get the current screen resources"); } else { @@ -300,8 +302,8 @@ void QXcbConnection::initializeScreens() timestamp = resources_current->config_timestamp; outputs = xcb_randr_get_screen_resources_current_outputs(resources_current.get()); } else { - auto resources = Q_XCB_REPLY(xcb_randr_get_screen_resources, - xcb_connection(), xcbScreen->root); + resources = Q_XCB_REPLY(xcb_randr_get_screen_resources, + xcb_connection(), xcbScreen->root); if (!resources) { qWarning("failed to get the screen resources"); } else { |