rusticl/api: protect against 0 length in slice::from_raw_parts

Fixes: 84d16045d0 ("rusticl/api: add param to query which contains application provided values")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30410>
(cherry picked from commit 81f75e2a2d)
This commit is contained in:
Karol Herbst 2024-07-29 14:41:09 +02:00 committed by Eric Engestrom
parent fb663417c7
commit 68feb29646
2 changed files with 2 additions and 2 deletions

View file

@ -134,7 +134,7 @@
"description": "rusticl/api: protect against 0 length in slice::from_raw_parts",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "84d16045d034cf34e782febea7cf7d933b730ba6",
"notes": null

View file

@ -26,7 +26,7 @@ pub trait CLInfo<I> {
param_value: *mut ::std::os::raw::c_void,
param_value_size_ret: *mut usize,
) -> CLResult<()> {
let arr = if !param_value.is_null() {
let arr = if !param_value.is_null() && param_value_size != 0 {
unsafe { slice::from_raw_parts(param_value.cast(), param_value_size) }
} else {
&[]