[PATCH] Fix write to uninitialized bytes for XCB event

Enrico Forestieri forenr at lyx.org
Sun Feb 23 14:10:37 UTC 2020


On Sun, Feb 23, 2020 at 08:22:55AM -0500, Scott Kostyshak wrote:
> On Wed, Feb 19, 2020 at 08:07:46PM +0100, Enrico Forestieri wrote:
> > On Wed, Feb 19, 2020 at 01:19:54PM -0500, Scott Kostyshak wrote:
> > > 
> > > It seems I committed too soon. Sorry for not waiting. Both the macro
> > > approach and Enrico's proposal are cleaner than my approach. I was
> > > planning to pursue the macro approach in a follow-up commit.
> > 
> > Apparently, the macro approach was abandoned by the Qt folks.
> > 
> > > Regarding
> > > C++11, don't we already use range-based for loops? Or is the question
> > > about if we require *all* of C++11?
> > 
> > The latter. As shown by Pavel in the other post gcc 4.7 is lacking
> > something. As we use xcb_selection_notify_event_t only in one place,
> > I think defining a macro is overkill. In order to avoid many calls
> > to calloc() (I don't know how memory fragmentation is dealt with by
> > modern compilers), we could anyway use that idea as follows:
> > 
> > 	union {
> > 		xcb_selection_notify_event_t event;
> > 		char padding[32];
> > 	} padded_event;
> > 	auto & nev = padded_event.event;
> 
> Enrico, I propose that you commit. Thanks for the fix.

According to the followups to the post by Pavel and commit 748bb5a0,
I think that the C++11 alignas solution is preferred. Given that you
can check its effectiveness, I think that it is better that you
commit it.

-- 
Enrico


More information about the lyx-devel mailing list