diff options
author | Luo Xionghu <xionghu.luo@intel.com> | 2015-09-21 15:51:26 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2015-09-21 16:32:17 +0800 |
commit | 4201ee5de9c06c504f949fcc2064bb0f441a347b (patch) | |
tree | bc3a2933a78bac5bd242c9da119b35308fd3aed0 /src | |
parent | 0b4927fd2ef398cd91b33788e13aecb43c967957 (diff) |
should check the return value of cl_program_new.
catch the error: out of host memery.
Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/cl_program.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cl_program.c b/src/cl_program.c index 0564b6f7..82dd3e34 100644 --- a/src/cl_program.c +++ b/src/cl_program.c @@ -224,6 +224,10 @@ cl_program_create_from_binary(cl_context ctx, } program = cl_program_new(ctx); + if (UNLIKELY(program == NULL)) { + err = CL_OUT_OF_HOST_MEMORY; + goto error; + } // TODO: Need to check the binary format here to return CL_INVALID_BINARY. TRY_ALLOC(program->binary, cl_calloc(lengths[0], sizeof(char))); @@ -379,6 +383,11 @@ cl_program_create_from_llvm(cl_context ctx, INVALID_VALUE_IF (file_name == NULL); program = cl_program_new(ctx); + if (UNLIKELY(program == NULL)) { + err = CL_OUT_OF_HOST_MEMORY; + goto error; + } + program->opaque = compiler_program_new_from_llvm(ctx->device->device_id, file_name, NULL, NULL, NULL, program->build_log_max_sz, program->build_log, &program->build_log_sz, 1); if (UNLIKELY(program->opaque == NULL)) { err = CL_INVALID_PROGRAM; @@ -417,6 +426,11 @@ cl_program_create_from_source(cl_context ctx, // the real compilation step will be done at build time since we do not have // yet the compilation options program = cl_program_new(ctx); + if (UNLIKELY(program == NULL)) { + err = CL_OUT_OF_HOST_MEMORY; + goto error; + } + TRY_ALLOC (lens, cl_calloc(count, sizeof(int32_t))); for (i = 0; i < (int) count; ++i) { size_t len; @@ -633,6 +647,10 @@ cl_program_link(cl_context context, } p = cl_program_new(context); + if (UNLIKELY(p == NULL)) { + err = CL_OUT_OF_HOST_MEMORY; + goto error; + } if (!check_cl_version_option(p, options)) { err = CL_BUILD_PROGRAM_FAILURE; |