[LyX/master] Revert "Fix write to uninitialized bytes for XCB event"

Enrico Forestieri forenr at lyx.org
Tue Feb 25 11:19:55 UTC 2020


commit 89772960781f0ee0fe493776da1fbd7cd91e1215
Author: Enrico Forestieri <forenr at lyx.org>
Date:   Tue Feb 25 12:32:10 2020 +0100

    Revert "Fix write to uninitialized bytes for XCB event"
    
    This reverts commit 19c41bd09572f15ac3546c8e6a6d4ec15306c93a.
    
    A more efficient fix is on the way.
---
 src/frontends/qt/GuiApplication.cpp |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index 2cdd5f6..8fdd9bf 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -3352,26 +3352,18 @@ bool GuiApplication::nativeEventFilter(const QByteArray & eventType,
 				// not doing that, maybe because of our
 				// "persistent selection" implementation
 				// (see comments in GuiSelection.cpp).
-
-				// It is expected that every X11 event is 32 bytes long,
-				// even if not all 32 bytes are needed. See:
-				// https://www.x.org/releases/current/doc/man/man3/xcb_send_event.3.xhtml
-				// TODO switch to Q_DECLARE_XCB_EVENT(event, xcb_selection_notify_event_t)
-				//      once we require qt >= 5.6.3 or just copy the macro def.
-				xcb_selection_notify_event_t *nev = (xcb_selection_notify_event_t*) calloc(32, 1);
-
-				nev->response_type = XCB_SELECTION_NOTIFY;
-				nev->requestor = srev->requestor;
-				nev->selection = srev->selection;
-				nev->target = srev->target;
-				nev->property = XCB_NONE;
-				nev->time = XCB_CURRENT_TIME;
+				xcb_selection_notify_event_t nev;
+				nev.response_type = XCB_SELECTION_NOTIFY;
+				nev.requestor = srev->requestor;
+				nev.selection = srev->selection;
+				nev.target = srev->target;
+				nev.property = XCB_NONE;
+				nev.time = XCB_CURRENT_TIME;
 				xcb_connection_t * con = QX11Info::connection();
 				xcb_send_event(con, 0, srev->requestor,
 					XCB_EVENT_MASK_NO_EVENT,
-					reinterpret_cast<char const *>(nev));
+					reinterpret_cast<char const *>(&nev));
 				xcb_flush(con);
-				free(nev);
 #endif
 				return true;
 			}


More information about the lyx-cvs mailing list