[JANITOR] Request for review
Keith Packard
keithp at keithp.com
Sat Aug 6 05:30:33 UTC 2016
Kayo Hamid <khflab at gmail.com> writes:
> I'm trying to do one janitor task looking for bad allocations. Someone
> could review my diff and see if is okay?
>
> Thanks.
>
> --
> Kayo Hamid
> diff --git a/dix/enterleave.c b/dix/enterleave.c
> index 1b341f2..8cec9a2 100644
> --- a/dix/enterleave.c
> +++ b/dix/enterleave.c
> @@ -715,6 +715,13 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
> }
>
> sev = ev = xallocarray(evcount, sizeof(xEvent));
> +
> + if(!ev) {
> + free(ev);
> + free(sev);
> + return BadAlloc;
> + }
> +
Good catch on the allocation failure, but in this case you don't need to
free anything, and you should make sure your code compiles without
warnings as this function is void, and so wouldn't need a return value.
--
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 810 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20160805/7cd7f456/attachment.sig>
More information about the xorg-devel
mailing list