intel: Add a null pointer check before dereferencing the pointer
authorAnuj Phogat <anuj.phogat@gmail.com>
Tue, 16 Apr 2013 17:34:43 +0000 (10:34 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Wed, 17 Apr 2013 15:17:47 +0000 (08:17 -0700)
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/intel/intel_screen.c

index 16750f2717e6060d4a8c7ba36b18bee85f10f8ef..00e7bc6cb77492aaa090191693b5243f7f6d4938 100644 (file)
@@ -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);