[Mesa-dev] [PATCH] clover: fix clCreateContext Piglit test crash

EdB edb+mesa at sigluy.net
Wed Nov 12 03:14:18 PST 2014


clCreateContext no longer crash when CL_CONTEXT_PLATFORM is invalid
---
 src/gallium/state_trackers/clover/api/context.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/context.cpp b/src/gallium/state_trackers/clover/api/context.cpp
index 021eea3..749d2d7 100644
--- a/src/gallium/state_trackers/clover/api/context.cpp
+++ b/src/gallium/state_trackers/clover/api/context.cpp
@@ -39,10 +39,15 @@ clCreateContext(const cl_context_properties *d_props, cl_uint num_devs,
       throw error(CL_INVALID_VALUE);
 
    for (auto &prop : props) {
-      if (prop.first == CL_CONTEXT_PLATFORM)
-         obj(prop.second.as<cl_platform_id>());
-      else
+      if (prop.first == CL_CONTEXT_PLATFORM) {
+         //clover only have one platform
+         cl_platform_id d_platform;
+         cl_int ret = clGetPlatformIDs(1, &d_platform, NULL);
+         if (ret || (prop.second.as<cl_platform_id>() != d_platform))
+            throw error(CL_INVALID_PLATFORM);
+      } else {
          throw error(CL_INVALID_PROPERTY);
+      }
    }
 
    ret_error(r_errcode, CL_SUCCESS);
-- 
1.9.3



More information about the mesa-dev mailing list