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

Lucas Stach l.stach at pengutronix.de
Mon Jun 8 03:45:06 PDT 2015


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
-- 
2.1.4



More information about the Piglit mailing list