Skip to content

Commit

Permalink
xcb: avoid to use invalid pointers
Browse files Browse the repository at this point in the history
Pick-to: 6.2 5.15 5.12
Task-number: QTBUG-96399
Change-Id: I33909940b501cb13f78981c43f3aef9fc9d1d52d
Reviewed-by: Shawn Rutledge <[email protected]>
  • Loading branch information
liangqi committed Oct 22, 2021
1 parent 606124c commit e093822
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/plugins/platforms/xcb/qxcbconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,13 @@ xcb_timestamp_t QXcbConnection::getTimestamp()

xcb_window_t QXcbConnection::getSelectionOwner(xcb_atom_t atom) const
{
return Q_XCB_REPLY(xcb_get_selection_owner, xcb_connection(), atom)->owner;
auto reply = Q_XCB_REPLY(xcb_get_selection_owner, xcb_connection(), atom);
if (!reply) {
qCDebug(lcQpaXcb) << "failed to query selection owner";
return XCB_NONE;
}

return reply->owner;
}

xcb_window_t QXcbConnection::getQtSelectionOwner()
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/platforms/xcb/qxcbconnection_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ xcb_atom_t QXcbBasicConnection::internAtom(const char *name)
if (!name || *name == 0)
return XCB_NONE;

return Q_XCB_REPLY(xcb_intern_atom, m_xcbConnection, false, strlen(name), name)->atom;
auto reply = Q_XCB_REPLY(xcb_intern_atom, m_xcbConnection, false, strlen(name), name);
if (!reply) {
qCDebug(lcQpaXcb) << "failed to query intern atom: " << name;
return XCB_NONE;
}

return reply->atom;
}

QByteArray QXcbBasicConnection::atomName(xcb_atom_t atom)
Expand Down

0 comments on commit e093822

Please sign in to comment.