[PATCH] Check for OOM condition in XISendDeviceHierarchyEvent

Peter Hutterer peter.hutterer at who-t.net
Wed Feb 16 21:38:22 PST 2011


On Wed, Feb 16, 2011 at 04:55:57PM -0800, Bryce Harrington wrote:
> When system is out of memory, calloc can fail returning a NULL pointer.
> Check for this before dereferencing it, and bail out if it fails.
> 
> Ref.: https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/720445
> 
> Signed-off-by: Bryce Harrington <bryce at canonical.com>
> ---

merged, thanks. but I'd be very very surprised if we'd survive for long if
we're really OOM.

Cheers,
  Peter

>  Xi/xichangehierarchy.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
> index b9cdedf..21c74ed 100644
> --- a/Xi/xichangehierarchy.c
> +++ b/Xi/xichangehierarchy.c
> @@ -70,6 +70,8 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
>  
>      ev = calloc(1, sizeof(xXIHierarchyEvent) +
>                   MAXDEVICES * sizeof(xXIHierarchyInfo));
> +    if (!ev)
> +        return;
>      ev->type = GenericEvent;
>      ev->extension = IReqCode;
>      ev->evtype = XI_HierarchyChanged;
> -- 
> 1.7.2.3


More information about the xorg-devel mailing list