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

Eric Engestrom eric at engestrom.ch
Mon Sep 4 07:06:34 UTC 2017


On Monday, 2017-09-04 04:54:36 +0000, Jason Ekstrand wrote:
> I sent the same patch a few hours later.  I don't care which one we land.
> You have a more descriptive commit message.

Alright then, I just pushed mine.

> 
> 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
> >


More information about the mesa-dev mailing list