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

Samuel Iglesias Gonsálvez siglesias at igalia.com
Mon Sep 4 05:06:34 UTC 2017


Reviewed-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>

On Sun, 2017-09-03 at 21:54 -0700, 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.
> 
> 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
> > 
> > 
> 
> _______________________________________________
> 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/20170904/92ea2a04/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170904/92ea2a04/attachment.sig>


More information about the mesa-dev mailing list