Skip to content

Commit

Permalink
Fix sporadic crash in QXcbScreen::getOutputProperty()
Browse files Browse the repository at this point in the history
Although [0] claims "This request does never generate any errors", it
seems I sometimes get back a NULL pointer from
xcb_randr_get_output_property_reply(), leading to a segfault (in the
qdatetimeedit auto-test).  So check reply isn't NULL before
dereferencing it.

[0] https://www.systutorials.com/docs/linux/man/3-xcb_randr_get_output_property_reply/

Change-Id: Iadae835bb3017bf9bb40f180b75b0c391384f99b
Reviewed-by: Gatis Paeglis <[email protected]>
  • Loading branch information
ediosyncratic authored and gatispaeglis committed Jun 28, 2017
1 parent 3ffcfc3 commit 634f28f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/platforms/xcb/qxcbscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ QByteArray QXcbScreen::getOutputProperty(xcb_atom_t atom) const
xcb_randr_get_output_property(xcb_connection(), m_output,
atom, XCB_ATOM_ANY, 0, 100, false, false);
auto reply = xcb_randr_get_output_property_reply(xcb_connection(), cookie, nullptr);
if (reply->type == XCB_ATOM_INTEGER && reply->format == 8) {
if (reply && reply->type == XCB_ATOM_INTEGER && reply->format == 8) {
quint8 *data = new quint8[reply->num_items];
memcpy(data, xcb_randr_get_output_property_data(reply), reply->num_items);
result = QByteArray(reinterpret_cast<const char *>(data), reply->num_items);
Expand Down

0 comments on commit 634f28f

Please sign in to comment.