diff --git a/examples/cxx/publish_subscribe_dynamic_data/README.md b/examples/cxx/publish_subscribe_dynamic_data/README.md index 79548170e..9e1a96fcd 100644 --- a/examples/cxx/publish_subscribe_dynamic_data/README.md +++ b/examples/cxx/publish_subscribe_dynamic_data/README.md @@ -15,9 +15,9 @@ allowing users to send samples of arbitrary sizes. > * have a uniform memory representation -> `#[repr(C)]` > * not use pointers to manage their internal structure > -> Data types like `String` or `Vec` will cause undefined behavior and may -> result in segmentation faults. We provide alternative data types that are -> compatible with shared memory. See the +> Data types like `std::string` or `std::vector` will cause undefined behavior +> and may result in segmentation faults. We provide alternative data types +> that are compatible with shared memory. See the > [complex data type example](../complex_data_types) for guidance on how to > use them. diff --git a/iceoryx2/src/port/publisher.rs b/iceoryx2/src/port/publisher.rs index 0d4e831a6..b0703da32 100644 --- a/iceoryx2/src/port/publisher.rs +++ b/iceoryx2/src/port/publisher.rs @@ -261,6 +261,7 @@ impl SegmentState { } fn sample_index(&self, distance_to_chunk: usize) -> usize { + debug_assert!(distance_to_chunk % self.payload_size() == 0); distance_to_chunk / self.payload_size() }