[PATCH] Check MGAAllocAdaptor() for memory allocation failure

Mark Kettenis mark.kettenis at xs4all.nl
Thu Dec 29 00:52:51 PST 2011


> From: Alan Coopersmith <alan.coopersmith at oracle.com>
> Date: Wed, 28 Dec 2011 19:51:04 -0800
> 
> If it couldn't allocate memory, don't attempt to write a bunch of values
> to the NULL pointer before returning it, but just pass the NULL along
> right away.
> 
> Resolves parfait warnings of the form:
> 
> Error: Null pointer dereference (CWE 476)
>    Write to null pointer 'adapt'
>         at line 322 of src/mga_video.c in function 'MGASetupImageVideoTexture'.
>           Function 'MGAAllocAdaptor' may return constant 'NULL' at line 237, called at line 320.
>           Null pointer introduced at line 237 in function 'MGAAllocAdaptor'.
> 
> repeated for every line writing to the adapt pointer in each function.
> 
> [ This bug was found by the Parfait 0.4.2 bug checking tool.
>   For more information see http://labs.oracle.com/projects/parfait/ ]
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
>  src/mga_video.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)

Can't make things worse.

Reviewed-by: Mark Kettenis <kettenis at openbsd.org>


More information about the xorg-devel mailing list