[Mesa-dev] [PATCH] anv/formats: Fix an off-by-one in the format array range check

Jason Ekstrand jason at jlekstrand.net
Mon Sep 4 00:10:46 UTC 2017


Found with static code analysis

Cc: mesa-stable at lists.freedesktop.org
---
 src/intel/vulkan/anv_formats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index c23b143..eead1aa 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -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;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list