Skip to content

Commit

Permalink
Handle null ptr in fmt_labels
Browse files Browse the repository at this point in the history
  • Loading branch information
patowen committed May 3, 2024
1 parent df553de commit 739549e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/src/graphics/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ unsafe extern "system" fn messenger_callback(
_p_user_data: *mut c_void,
) -> vk::Bool32 {
unsafe fn fmt_labels(ptr: *const vk::DebugUtilsLabelEXT, count: u32) -> String {
if count == 0 {
// We need to handle a count of 0 separately because ptr may be
// null, resulting in undefined behavior if used with
// slice::from_raw_parts.
return String::new();
}
slice::from_raw_parts(ptr, count as usize)
.iter()
.map(|label| {
Expand Down

0 comments on commit 739549e

Please sign in to comment.