diff options
author | Luo Xionghu <xionghu.luo@intel.com> | 2016-05-06 00:11:47 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-05-23 18:07:21 +0800 |
commit | 0ad68c09087b2fab4b1ff2ebc9ed38ea0258794c (patch) | |
tree | f70ad6a3ad08f579dcb587188253e3452b40959f /utests/utest_helper.cpp | |
parent | d30f395244949742f8a0aad83e8720d3c50f0fe1 (diff) | |
download | beignet-0ad68c09087b2fab4b1ff2ebc9ed38ea0258794c.tar.gz |
utest: error handling to avoid null pointer dereference.
Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'utests/utest_helper.cpp')
-rw-r--r-- | utests/utest_helper.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp index 4d2d4df6..01feb592 100644 --- a/utests/utest_helper.cpp +++ b/utests/utest_helper.cpp @@ -241,6 +241,10 @@ cl_kernel_init(const char *file_name, const char *kernel_name, int format, const assert(0); } else if (format == SOURCE) { cl_file_map_t *fm = cl_file_map_new(); + if(!fm) { + fprintf(stderr, "run out of memory\n"); + goto error; + } FATAL_IF (cl_file_map_open(fm, ker_path) != CL_FILE_MAP_SUCCESS, "Failed to open file \"%s\" with kernel \"%s\". Did you properly set OCL_KERNEL_PATH variable?", file_name, kernel_name); @@ -292,6 +296,10 @@ cl_kernel_compile(const char *file_name, const char *kernel_name, const char * c if (program) clReleaseProgram(program); ker_path = cl_do_kiss_path(file_name, device); cl_file_map_t *fm = cl_file_map_new(); + if(!fm) { + fprintf(stderr, "run out of memory\n"); + goto error; + } FATAL_IF (cl_file_map_open(fm, ker_path) != CL_FILE_MAP_SUCCESS, "Failed to open file \"%s\" with kernel \"%s\". Did you properly set OCL_KERNEL_PATH variable?", file_name, kernel_name); @@ -339,6 +347,10 @@ cl_kernel_link(const char *file_name, const char *kernel_name, const char * link if (program) clReleaseProgram(program); ker_path = cl_do_kiss_path(file_name, device); cl_file_map_t *fm = cl_file_map_new(); + if(!fm) { + fprintf(stderr, "run out of memory\n"); + goto error; + } FATAL_IF (cl_file_map_open(fm, ker_path) != CL_FILE_MAP_SUCCESS, "Failed to open file \"%s\" with kernel \"%s\". Did you properly set OCL_KERNEL_PATH variable?", file_name, kernel_name); |