anv: fix off by one in array check
authorEric Engestrom <eric@engestrom.ch>
Sun, 3 Sep 2017 18:22:06 +0000 (19:22 +0100)
committerEric Engestrom <eric@engestrom.ch>
Mon, 4 Sep 2017 07:05:36 +0000 (08:05 +0100)
`anv_formats[ARRAY_SIZE(anv_formats)]` is already one too far.
Spotted by Coverity.

CovID: 1417259
Fixes: 242211933a0682696170 "anv/formats: Nicely handle unknown VkFormat enums"
Cc: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/intel/vulkan/anv_formats.c

index c23b143cac2272caf72f7cc4d958975e344ed99b..eead1aa790926753f50cedd39ac0f3b3389a660d 100644 (file)
@@ -253,7 +253,7 @@ static const struct anv_format anv_formats[] = {
 static bool
 format_supported(VkFormat vk_format)
 {
-   if (vk_format > ARRAY_SIZE(anv_formats))
+   if (vk_format >= ARRAY_SIZE(anv_formats))
       return false;
 
    return anv_formats[vk_format].isl_format != ISL_FORMAT_UNSUPPORTED;