[PATCH xserver] dix: Don't leak swapped events

Keith Packard keithp at keithp.com
Wed Mar 29 16:05:00 UTC 2017


Peter Hutterer <peter.hutterer at who-t.net> writes:

> as keith already pointed out, this will break for generic events. but you
> can still get the same effect by switching to
>    unsigned char buffer[eventlength];
>    xEvent *swapped = buffer;
> and get rid of the heap allocation this way.

You'll have to use 'uint64_t buffer[eventlength/8]' to  get the
alignment fixed up, but otherwise, this looks good. Although, frankly,
having a malloc'd buffer which gets resized as necessary is far from the
worse thing this code could do, and avoids stack overflow problems if
'eventlength' turns out to be mis-computed.

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20170329/7e1f36af/attachment.sig>


More information about the xorg-devel mailing list