[Mesa-dev] [PATCH V2] intel: Add a null pointer check before dereferencing the pointer

Matt Turner mattst88 at gmail.com
Tue Apr 16 16:37:18 PDT 2013


On Tue, Apr 16, 2013 at 4:13 PM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
>
> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
> ---
>  src/mesa/drivers/dri/intel/intel_screen.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
> index 16750f2..00e7bc6 100644
> --- a/src/mesa/drivers/dri/intel/intel_screen.c
> +++ b/src/mesa/drivers/dri/intel/intel_screen.c
> @@ -368,6 +368,9 @@ intel_create_image_from_name(__DRIscreen *screen,
>      int cpp;
>
>      image = intel_allocate_image(format, loaderPrivate);
> +    if (image == NULL)
> +       return NULL;
> +
>      if (image->format == MESA_FORMAT_NONE)
>         cpp = 1;
>      else
> @@ -504,6 +507,9 @@ intel_create_image(__DRIscreen *screen,
>     }
>
>     image = intel_allocate_image(format, loaderPrivate);
> +   if (image == NULL)
> +      return NULL;
> +
>     cpp = _mesa_get_format_bytes(image->format);
>     image->region =
>        intel_region_alloc(intelScreen, tiling, cpp, width, height, true);
> @@ -707,6 +713,9 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
>      stride = parent->strides[index];
>
>      image = intel_allocate_image(dri_format, loaderPrivate);
> +    if (image == NULL)
> +       return NULL;
> +
>      if (offset + height * stride > parent->region->bo->size) {
>         _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
>         free(image);
> --
> 1.8.1.4

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-dev mailing list