We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9fdedc4 commit 2b215e8Copy full SHA for 2b215e8
rosidl_runtime_rs/src/sequence.rs
@@ -510,8 +510,10 @@ macro_rules! impl_sequence_alloc_for_primitive_type {
510
unsafe {
511
// This allocates space and sets seq.size and seq.capacity to size
512
let ret = $init_func(seq as *mut _, size);
513
- // Zero memory, since it will be uninitialized if there is no default value
514
- std::ptr::write_bytes(seq.data, 0u8, size);
+ if !seq.data.is_null() {
+ // Zero memory, since it will be uninitialized if there is no default value
515
+ std::ptr::write_bytes(seq.data, 0u8, size);
516
+ }
517
ret
518
}
519
0 commit comments