summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShow Liu <show.liu@linaro.org>2014-12-05 16:02:32 +0800
committerShow Liu <show.liu@linaro.org>2014-12-05 16:02:32 +0800
commite5db4273b82c5c6b7bae266b8a4e2fe67feb62a0 (patch)
treed9b204dd49fb2e486cea1d1b3264abf2458e70ca
parent5d2eb9a1fc2ea97f717f1f819a088364412c9ddc (diff)
downloadshamrock-create_kernels_in_program.tar.gz
Fixed the segmentation fault by check the kernels isn't null in kernellist.create_kernels_in_program
-rw-r--r--src/api/api_kernel.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/api/api_kernel.cpp b/src/api/api_kernel.cpp
index abc492b..89f1d4a 100644
--- a/src/api/api_kernel.cpp
+++ b/src/api/api_kernel.cpp
@@ -29,7 +29,6 @@
* \file api_kernel.cpp
* \brief Kernels
*/
-
#include "CL/cl.h"
#include <core/program.h>
@@ -83,6 +82,7 @@ clCreateKernelsInProgram(cl_program program,
cl_uint * num_kernels_ret)
{
cl_int rs = CL_SUCCESS;
+ Coal::Kernel *tmpKernel;
if (!program->isA(Coal::Object::T_Program))
return CL_INVALID_PROGRAM;
@@ -92,11 +92,15 @@ clCreateKernelsInProgram(cl_program program,
std::vector<Coal::Kernel *> ks = program->createKernels(&rs);
+
if (rs != CL_SUCCESS)
{
while (ks.size())
{
- delete ks.back();
+ tmpKernel = ks.back();
+ if(!tmpKernel)
+ delete tmpKernel;
+ //delete ks.back();
ks.pop_back();
}
@@ -111,7 +115,10 @@ clCreateKernelsInProgram(cl_program program,
{
while (ks.size())
{
- delete ks.back();
+ tmpKernel = ks.back();
+ if(!tmpKernel)
+ delete tmpKernel;
+ //delete ks.back();
ks.pop_back();
}