summaryrefslogtreecommitdiff
path: root/utests/get_cl_info.cpp
diff options
context:
space:
mode:
authorLuo Xionghu <xionghu.luo@intel.com>2016-05-06 00:11:47 +0800
committerYang Rong <rong.r.yang@intel.com>2016-05-23 18:07:21 +0800
commit0ad68c09087b2fab4b1ff2ebc9ed38ea0258794c (patch)
treef70ad6a3ad08f579dcb587188253e3452b40959f /utests/get_cl_info.cpp
parentd30f395244949742f8a0aad83e8720d3c50f0fe1 (diff)
downloadbeignet-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/get_cl_info.cpp')
-rw-r--r--utests/get_cl_info.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/utests/get_cl_info.cpp b/utests/get_cl_info.cpp
index 25366902..bdd7e0c0 100644
--- a/utests/get_cl_info.cpp
+++ b/utests/get_cl_info.cpp
@@ -181,9 +181,15 @@ void get_program_info(void)
int sz;
char *ker_path = (char *)malloc(4096 * sizeof(char));
const char *kiss_path = getenv("OCL_KERNEL_PATH");
+ if(!kiss_path)
+ return;
+
string line;
string source_code;
+ if(strlen(kiss_path) > 4000)
+ return;
+
sprintf(ker_path, "%s/%s", kiss_path, "compiler_if_else.cl");
ifstream in(ker_path);