mirror of
https://github.com/encounter/rust-ffmpeg.git
synced 2026-07-10 21:18:39 -07:00
*: check unsafe slice creation
This commit is contained in:
@@ -88,13 +88,15 @@ impl<'a> Vector<'a> {
|
||||
|
||||
pub fn coefficients(&self) -> &[f64] {
|
||||
unsafe {
|
||||
slice::from_raw_parts((*self.as_ptr()).coeff, (*self.as_ptr()).length as usize)
|
||||
slice::from_raw_parts((*self.as_ptr()).coeff,
|
||||
(*self.as_ptr()).length as usize)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn coefficients_mut(&self) -> &[f64] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut((*self.as_ptr()).coeff, (*self.as_ptr()).length as usize)
|
||||
slice::from_raw_parts_mut((*self.as_ptr()).coeff,
|
||||
(*self.as_ptr()).length as usize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,8 @@ impl Index<usize> for Buffer {
|
||||
}
|
||||
|
||||
unsafe {
|
||||
slice::from_raw_parts(*self.buffer.offset(index as isize), self.size as usize)
|
||||
slice::from_raw_parts(*self.buffer.offset(index as isize),
|
||||
self.size as usize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,9 +157,8 @@ impl Audio {
|
||||
}
|
||||
|
||||
unsafe {
|
||||
slice::from_raw_parts(
|
||||
mem::transmute((*self.as_ptr()).data[index]),
|
||||
mem::size_of::<T>() * self.samples())
|
||||
slice::from_raw_parts(mem::transmute((*self.as_ptr()).data[index]),
|
||||
self.samples())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,9 +173,8 @@ impl Audio {
|
||||
}
|
||||
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(
|
||||
mem::transmute((*self.as_mut_ptr()).data[index]),
|
||||
mem::size_of::<T>() * self.samples())
|
||||
slice::from_raw_parts_mut(mem::transmute((*self.as_mut_ptr()).data[index]),
|
||||
self.samples())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ impl Video {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane_mut<T: Component>(&mut self, index: usize) -> &mut[T] {
|
||||
pub fn plane_mut<T: Component>(&mut self, index: usize) -> &mut [T] {
|
||||
if index >= self.planes() {
|
||||
panic!("out of bounds");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user