[Piglit] [PATCH] cl-tests: don't pass NULL ptr to initial strtok call

Lucas Stach l.stach at pengutronix.de
Mon Jun 15 01:22:55 PDT 2015


Given that this patch is really trivial, I'm going to push this by
tomorrow if nobody objects.

Regards,
Lucas

Am Montag, den 08.06.2015, 12:45 +0200 schrieb Lucas Stach:
> If the test don't require specific extensions a NULL ptr is
> passed to the initial call of strtok(). Apparently this works on
> x86, but it is undocumented behavior and crashes on other arches.
> 
> Fix the segfault by bailing out early in this case.
> 
> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> ---
>  tests/util/piglit-framework-cl.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tests/util/piglit-framework-cl.c b/tests/util/piglit-framework-cl.c
> index 9a7efef1d93b..9dc73c7e3508 100644
> --- a/tests/util/piglit-framework-cl.c
> +++ b/tests/util/piglit-framework-cl.c
> @@ -86,6 +86,9 @@ bool check_platform_extensions(cl_platform_id platform_id, char* extensions)
>  {
>  	char* pch;
>  
> +	if (!extensions)
> +		return true;
> +
>  	pch = strtok(extensions, " ");
>  	while(pch != NULL) {
>  		if(   strlen(pch) > 0
> @@ -108,6 +111,9 @@ bool check_device_extensions(cl_device_id device_id, char* extensions)
>  {
>  	char* pch;
>  
> +	if (!extensions)
> +		return true;
> +
>  	pch = strtok(extensions, " ");
>  	while(pch != NULL) {
>  		if(   strlen(pch) > 0

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |



More information about the Piglit mailing list