[Mesa-dev] [PATCH 1/5] mesa: Fix bogus strncmp

Samuel Iglesias Gonsálvez siglesias at igalia.com
Wed Jun 1 05:09:22 UTC 2016


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

On Tue, 2016-05-31 at 11:52 -0700, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> The string "[0]\0" is the same as "[0]" as far as the C string
> datatype
> is concerned.  That string has length 3.  strncmp(s, length_3_string,
> 4)
> is the same as strcmp(s, length_3_string), so make it be strcmp.
> 
> v2: Not the same as strncmp(..., 3).  Noticed by Ilia.
> 
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Cc: "12.0" <mesa-stable at lists.freedesktop.org>
> Cc: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
> ---
>  src/mesa/main/shader_query.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/mesa/main/shader_query.cpp
> b/src/mesa/main/shader_query.cpp
> index 28d8147..eec933c 100644
> --- a/src/mesa/main/shader_query.cpp
> +++ b/src/mesa/main/shader_query.cpp
> @@ -505,7 +505,7 @@ _mesa_program_resource_find_name(struct
> gl_shader_program *shProg,
>        if (rname_last_square_bracket) {
>           baselen_without_array_index -=
> strlen(rname_last_square_bracket);
>           rname_has_array_index_zero =
> -            (strncmp(rname_last_square_bracket, "[0]\0", 4) == 0) &&
> +            (strcmp(rname_last_square_bracket, "[0]") == 0) &&
>              (baselen_without_array_index == strlen(name));
>        }
>  
-------------- 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: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160601/f3cad3f4/attachment.sig>


More information about the mesa-dev mailing list