[Mesa-dev] [PATCH 3/3] mesa/main: check for null in invalid_array_element_syntax()
Kenneth Graunke
kenneth at whitecape.org
Tue May 5 09:45:19 PDT 2015
On Tuesday, May 05, 2015 01:50:59 PM Juha-Pekka Heikkila wrote:
> name string is coming through API call, need to be careful with it.
>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
> src/mesa/main/program_resource.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c
> index b15a132..2891827 100644
> --- a/src/mesa/main/program_resource.c
> +++ b/src/mesa/main/program_resource.c
> @@ -316,7 +316,7 @@ invalid_array_element_syntax(const GLchar *name)
> char *first = strchr(name, '[');
> char *last = strrchr(name, '[');
>
> - if (!first)
> + if (!first || !last)
> return false;
>
> /* No '+' or ' ' allowed anywhere. */
>
This patch is unnecessary - first and last will either both be NULL, or
both be non-NULL. You're searching for the same character ('[') in a
string forwards, then backwards. If it doesn't appear, both will be
NULL. If it does appear, both calls will find an occurance of that
character (possibly different).
-------------- 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/20150505/ad6c0d17/attachment.sig>
More information about the mesa-dev
mailing list