clover: add dynamic_cast results checking down in clSetKernelArgument() code path.
authorDmitry Cherkassov <dcherkassov@gmail.com>
Sat, 23 Mar 2013 19:51:22 +0000 (23:51 +0400)
committerFrancisco Jerez <currojerez@riseup.net>
Sun, 24 Mar 2013 01:43:34 +0000 (02:43 +0100)
Signed-off-by: Dmitry Cherkassov <dcherkassov@gmail.com>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
src/gallium/state_trackers/clover/core/kernel.cpp

index 6fa8bd63453c86f3d9e5aa7a840c5a6b92afadd6..20dc4ca57dda98cfd916c4ce756ccd12fe70e433 100644 (file)
@@ -222,6 +222,9 @@ _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 +289,9 @@ _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 +322,9 @@ _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 +355,9 @@ _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;
 }