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

Matt Turner mattst88 at gmail.com
Tue Apr 16 15:06:04 PDT 2013


On Tue, Apr 16, 2013 at 11:11 AM, 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 | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
> index 16750f2..27b992c 100644
> --- a/src/mesa/drivers/dri/intel/intel_screen.c
> +++ b/src/mesa/drivers/dri/intel/intel_screen.c
> @@ -707,6 +707,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

There is another place in the same file that the return value of
intel_allocate_image isn't checked. Should probably add a check there
while you're fixing this.


More information about the mesa-dev mailing list