[Mesa-dev] [PATCH] ralloc: don't write to memory in case of alloc fail.

Ian Romanick idr at freedesktop.org
Wed Apr 17 15:17:34 PDT 2013


On 04/16/2013 06:08 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> For some reason I made this happen under indirect rendering,
> I think we might have a leak, valgrind gave out, so I said I'd
> fix the basic problem.

NOTE: This is a candidate for stable branches.

> Signed-off-by: Dave Airlie <airlied at redhat.com>

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> ---
>   src/glsl/ralloc.c |    2 ++
>   1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/src/glsl/ralloc.c b/src/glsl/ralloc.c
> index 59e71c4..0281642 100644
> --- a/src/glsl/ralloc.c
> +++ b/src/glsl/ralloc.c
> @@ -108,6 +108,8 @@ ralloc_size(const void *ctx, size_t size)
>   {
>      void *block = calloc(1, size + sizeof(ralloc_header));
>
> +   if (unlikely(block == NULL))
> +      return NULL;
>      ralloc_header *info = (ralloc_header *) block;
>      ralloc_header *parent = ctx != NULL ? get_header(ctx) : NULL;
>
>



More information about the mesa-dev mailing list