[Mesa-dev] [PATCH mesa] anv: fix off by one in array check

Jason Ekstrand jason at jlekstrand.net
Mon Sep 4 04:54:23 UTC 2017


I sent the same patch a few hours later.  I don't care which one we land.
You have a more descriptive commit message.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

On Sun, Sep 3, 2017 at 11:33 AM, Eric Engestrom <eric at engestrom.ch> wrote:

> `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 at intel.com>
> Signed-off-by: Eric Engestrom <eric at engestrom.ch>
> ---
>  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 c23b143cac..eead1aa790 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;
> --
> Cheers,
>   Eric
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170903/23ee55ae/attachment.html>


More information about the mesa-dev mailing list