diff --git a/opencl/api/opencl/amdocl/cl_common.hpp b/opencl/api/opencl/amdocl/cl_common.hpp index 4674ebd0f4..b49ec76a42 100644 --- a/opencl/api/opencl/amdocl/cl_common.hpp +++ b/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