gbm: Assert modifiers and count are copacetic
authorBen Widawsky <ben@bwidawsk.net>
Wed, 5 Apr 2017 17:31:45 +0000 (10:31 -0700)
committerBen Widawsky <ben@bwidawsk.net>
Sun, 9 Apr 2017 16:29:57 +0000 (09:29 -0700)
The API/entry point in mesa already checks the correct behavior,
however, it's possible to be handled by another implementation and those
implementations should not be able to abuse a weird combination of count
and pointer.

This fixes CID 1403193

Cc: Mark Janes <mark.a.janes@intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/gbm/backends/dri/gbm_dri.c

index 8df6a6b64d0b44bf77da468a41b15e0bd0dc3e59..71590d71103696efcaaa23ecdc051ae2bad5cc79 100644 (file)
@@ -1266,6 +1266,9 @@ gbm_dri_surface_create(struct gbm_device *gbm,
       return NULL;
    }
 
       return NULL;
    }
 
+   if (count)
+      assert(modifiers);
+
    /* It's acceptable to create an image with INVALID modifier in the list,
     * but it cannot be on the only modifier (since it will certainly fail
     * later). While we could easily catch this after modifier creation, doing
    /* It's acceptable to create an image with INVALID modifier in the list,
     * but it cannot be on the only modifier (since it will certainly fail
     * later). While we could easily catch this after modifier creation, doing