From 828b331808ec974e28ec240238730cc6b96cbf27 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 5 Oct 2016 13:52:10 -0400
Subject: [PATCH] P4 to Git Change 1322831 by lmoriche@lmoriche_opencl_dev on
2016/10/05 13:37:49
SWDEV-104457 - The spec says that the size allocated for value should be greater or equal to the size of the returned parameter. For string parameters, we should try to fill as much of the string as we can until we return an error.
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_common.hpp#18 edit
[ROCm/clr commit: ab39bb038d267787f423c21bd897fda489266cc2]
---
.../clr/opencl/api/opencl/amdocl/cl_common.hpp | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/projects/clr/opencl/api/opencl/amdocl/cl_common.hpp b/projects/clr/opencl/api/opencl/amdocl/cl_common.hpp
index 4674ebd0f4..b49ec76a42 100644
--- a/projects/clr/opencl/api/opencl/amdocl/cl_common.hpp
+++ b/projects/clr/opencl/api/opencl/amdocl/cl_common.hpp
@@ -152,11 +152,21 @@ clGetInfo(
std::tie(valuePtr, valueSize)
= detail::ParamInfo::type>::get(field);
+ *not_null(param_value_size_ret) = valueSize;
+
+ cl_int ret = CL_SUCCESS;
if (param_value != NULL && param_value_size < valueSize) {
- return CL_INVALID_VALUE;
+ if (!std::is_pointer() || !std::is_same::type>::type, char>()) {
+ return CL_INVALID_VALUE;
+ }
+ // For char* and char[] params, we will at least fill up to
+ // param_value_size, then return an error.
+ valueSize = param_value_size;
+ static_cast(param_value)[--valueSize] = '\0';
+ ret = CL_INVALID_VALUE;
}
- *not_null(param_value_size_ret) = valueSize;
if (param_value != NULL) {
::memcpy(param_value, valuePtr, valueSize);
if (param_value_size > valueSize) {
@@ -165,7 +175,7 @@ clGetInfo(
}
}
- return CL_SUCCESS;
+ return ret;
}
static inline cl_int