We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
PtrSlice::extend_from_slice
1 parent 29fbcce commit 485020bCopy full SHA for 485020b
glib/src/collections/ptr_slice.rs
@@ -796,12 +796,14 @@ impl<T: TransparentPtrType> PtrSlice<T> {
796
for item in other {
797
ptr::write(self.ptr.as_ptr().add(self.len) as *mut T, item.clone());
798
self.len += 1;
799
- }
800
801
- ptr::write(
802
- self.ptr.as_ptr().add(self.len),
803
- Ptr::from(ptr::null_mut::<<T as GlibPtrDefault>::GlibType>()),
804
- );
+ // Add null terminator on every iteration because `clone`
+ // may panic
+ ptr::write(
+ self.ptr.as_ptr().add(self.len),
+ Ptr::from(ptr::null_mut::<<T as GlibPtrDefault>::GlibType>()),
805
+ );
806
+ }
807
}
808
809
0 commit comments