Skip to content

Commit

Permalink
QXcb: don't dereference pointer before checking
Browse files Browse the repository at this point in the history
The virtualDesktop pointer is expected to be populated by queryPointer, but
that method handles the case that there either is no reply, or that the
reply doesn't match, in which case the pointer remains nullptr.

Don't dereference it afterwards without checking.

Addresses code checker warning a179d1087759bb6ca9c3380257bd70d6

Pick-to: 6.1 5.15
Change-Id: I5877f26fd3b49327c0de3f2c918bb606bee8ac57
Reviewed-by: Tor Arne Vestbø <[email protected]>
  • Loading branch information
vohi committed May 20, 2021
1 parent a5dc381 commit c2258e8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugins/platforms/xcb/qxcbcursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,8 @@ void QXcbCursor::setPos(const QPoint &pos)
{
QXcbVirtualDesktop *virtualDesktop = nullptr;
queryPointer(connection(), &virtualDesktop, nullptr);
xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y());
if (virtualDesktop)
xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y());
xcb_flush(xcb_connection());
}

Expand Down

0 comments on commit c2258e8

Please sign in to comment.