mirror of
https://github.com/encounter/rust-ffmpeg.git
synced 2026-07-10 21:18:39 -07:00
fix: use explicit types for lifetime transmutation
This fixes an accidental transmute (found by @projectgus) from an &Input to a &Context, which was only working accidentally by type layout coincidence. Co-Authored-By: Angus Gratton <gus@projectgus.com>
This commit is contained in:
committed by
Till Höppner
co-authored by
Angus Gratton
parent
10545c00d4
commit
eba4efef0c
@@ -15,10 +15,10 @@ pub struct ChapterMut<'a> {
|
||||
impl<'a> ChapterMut<'a> {
|
||||
pub unsafe fn wrap(context: &mut Context, index: usize) -> ChapterMut<'_> {
|
||||
ChapterMut {
|
||||
context: mem::transmute_copy(&context),
|
||||
context: mem::transmute::<&mut Context, &mut Context>(context),
|
||||
index,
|
||||
|
||||
immutable: Chapter::wrap(mem::transmute_copy(&context), index),
|
||||
immutable: Chapter::wrap(mem::transmute::<&Context, &Context>(context), index),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ impl<'a> Iterator for StreamIterMut<'a> {
|
||||
|
||||
unsafe {
|
||||
Some(StreamMut::wrap(
|
||||
mem::transmute_copy(&self.context),
|
||||
mem::transmute::<&mut Context, &mut Context>(self.context),
|
||||
(self.current - 1) as usize,
|
||||
))
|
||||
}
|
||||
@@ -349,7 +349,7 @@ impl<'a> Iterator for ChapterIterMut<'a> {
|
||||
self.current += 1;
|
||||
|
||||
Some(ChapterMut::wrap(
|
||||
mem::transmute_copy(&self.context),
|
||||
mem::transmute::<&mut Context, &mut Context>(self.context),
|
||||
(self.current - 1) as usize,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -181,10 +181,10 @@ impl<'a> Iterator for PacketIter<'a> {
|
||||
Err(Error::Eof) => None,
|
||||
|
||||
Ok(..) => unsafe {
|
||||
Some(Ok((
|
||||
Stream::wrap(mem::transmute_copy(&self.context), packet.stream()),
|
||||
packet,
|
||||
)))
|
||||
let context = mem::transmute::<&Context, &Context>(self.context);
|
||||
let stream = Stream::wrap(context, packet.stream());
|
||||
|
||||
Some(Ok((stream, packet)))
|
||||
},
|
||||
|
||||
Err(err) => Some(Err(err)),
|
||||
|
||||
@@ -13,10 +13,10 @@ pub struct StreamMut<'a> {
|
||||
impl<'a> StreamMut<'a> {
|
||||
pub unsafe fn wrap(context: &mut Context, index: usize) -> StreamMut<'_> {
|
||||
StreamMut {
|
||||
context: mem::transmute_copy(&context),
|
||||
context: mem::transmute::<&mut Context, &mut Context>(context),
|
||||
index,
|
||||
|
||||
immutable: Stream::wrap(mem::transmute_copy(&context), index),
|
||||
immutable: Stream::wrap(mem::transmute::<&Context, &Context>(context), index),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user