[Mesa-dev] [PATCH] clover: add dynamic_cast results checking down in clSetKernelArgument() code path.

Dmitry Cherkassov dcherkassov at gmail.com
Sat Mar 23 12:51:22 PDT 2013


Signed-off-by: Dmitry Cherkassov <dcherkassov at gmail.com>
---
 src/gallium/state_trackers/clover/core/kernel.cpp |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp
index 6fa8bd6..f664d79 100644
--- a/src/gallium/state_trackers/clover/core/kernel.cpp
+++ b/src/gallium/state_trackers/clover/core/kernel.cpp
@@ -222,6 +222,10 @@ _cl_kernel::global_argument::set(size_t size, const void *value) {
       throw error(CL_INVALID_ARG_SIZE);
 
    obj = dynamic_cast<clover::buffer *>(*(cl_mem *)value);
+
+   if (!obj)
+      throw error(CL_INVALID_MEM_OBJECT);
+
    __set = true;
 }
 
@@ -286,6 +290,10 @@ _cl_kernel::constant_argument::set(size_t size, const void *value) {
       throw error(CL_INVALID_ARG_SIZE);
 
    obj = dynamic_cast<clover::buffer *>(*(cl_mem *)value);
+
+   if (!obj)
+      throw error(CL_INVALID_MEM_OBJECT);
+
    __set = true;
 }
 
@@ -316,6 +324,10 @@ _cl_kernel::image_rd_argument::set(size_t size, const void *value) {
       throw error(CL_INVALID_ARG_SIZE);
 
    obj = dynamic_cast<clover::image *>(*(cl_mem *)value);
+
+   if (!obj)
+      throw error(CL_INVALID_MEM_OBJECT);
+
    __set = true;
 }
 
@@ -346,6 +358,10 @@ _cl_kernel::image_wr_argument::set(size_t size, const void *value) {
       throw error(CL_INVALID_ARG_SIZE);
 
    obj = dynamic_cast<clover::image *>(*(cl_mem *)value);
+
+   if (!obj)
+      throw error(CL_INVALID_MEM_OBJECT);
+
    __set = true;
 }
 
-- 
1.7.10.4



More information about the mesa-dev mailing list