[Mesa-dev] [PATCH 4/4] glsl: Fix off-by-one error in array size check assertion

Kenneth Graunke kenneth at whitecape.org
Wed Nov 18 10:05:30 PST 2015


On Wednesday, November 18, 2015 09:44:34 AM Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> Apparently, this has been a bug since 2010 (c30f6e5d).
> 
> Also use ARRAY_SIZE instead of open coding it.
> 
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> Cc: mesa-stable at lists.freedesktop.org
> ---
>  src/glsl/ir.cpp | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
> index 8b5ba71..80cbdbf 100644
> --- a/src/glsl/ir.cpp
> +++ b/src/glsl/ir.cpp
> @@ -1425,8 +1425,7 @@ static const char * const tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf
>  
>  const char *ir_texture::opcode_string()
>  {
> -   assert((unsigned int) op <=
> -	  sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]));
> +   assert((unsigned int) op < ARRAY_SIZE(tex_opcode_strs));
>     return tex_opcode_strs[op];
>  }
>  
> 

Good catch!

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151118/cdb6f925/attachment.sig>


More information about the mesa-dev mailing list