diff --git a/CHANGELOG.md b/CHANGELOG.md index 96b823a2f..c58f5894d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,10 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216). - Fix GL debug message callbacks not being properly cleaned up (causing UB). By @Imberflur in [#6114](https://github.com/gfx-rs/wgpu/pull/6114) +#### Vulkan + +- Vulkan debug labels assumed no interior nul byte. By @DJMcNab in [#6257](https://github.com/gfx-rs/wgpu/pull/6257) + ### Changes - `wgpu_hal::gles::Adapter::new_external` now requires the context to be current when dropping the adapter and related objects. By @Imberflur in [#6114](https://github.com/gfx-rs/wgpu/pull/6114). diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index 54905b4ba..181da3d88 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -15,6 +15,13 @@ use std::{ }; impl super::DeviceShared { + /// Set the name of `object` to `name`. + /// + /// If `name` contains an interior null byte, then the name set will be truncated to that byte. + /// + /// # Safety + /// + /// It must be valid to set `object`'s debug name pub(super) unsafe fn set_object_name(&self, object: impl vk::Handle, name: &str) { let Some(extension) = self.extension_fns.debug_utils.as_ref() else { return; @@ -44,7 +51,7 @@ impl super::DeviceShared { &buffer_vec }; - let name = unsafe { CStr::from_bytes_with_nul_unchecked(name_bytes) }; + let name = CStr::from_bytes_until_nul(name_bytes).expect("We have added a null byte"); let _result = unsafe { extension.set_debug_utils_object_name(