Commit 53d6be14 authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato
Browse files

crav1e: Fix Packet providing a dangling pointer

parent 69a6d29a
...@@ -253,11 +253,14 @@ pub unsafe extern "C" fn rav1e_receive_packet( ...@@ -253,11 +253,14 @@ pub unsafe extern "C" fn rav1e_receive_packet(
.receive_packet() .receive_packet()
.map(|p| { .map(|p| {
(*ctx).last_err = None; (*ctx).last_err = None;
let rav1e::Packet { data, number, frame_type, .. } = p;
let len = data.len();
let data = Box::into_raw(data.into_boxed_slice()) as *const u8;
let packet = Packet { let packet = Packet {
data: p.data.as_ptr(), data,
len: p.data.len(), len,
number: p.number, number,
frame_type: p.frame_type, frame_type,
}; };
*pkt = Box::into_raw(Box::new(packet)); *pkt = Box::into_raw(Box::new(packet));
0 0
...@@ -276,7 +279,8 @@ pub unsafe extern "C" fn rav1e_receive_packet( ...@@ -276,7 +279,8 @@ pub unsafe extern "C" fn rav1e_receive_packet(
#[no_mangle] #[no_mangle]
pub unsafe extern fn rav1e_packet_unref(pkt: *mut Packet) { pub unsafe extern fn rav1e_packet_unref(pkt: *mut Packet) {
if !pkt.is_null() { if !pkt.is_null() {
let _ = Box::from_raw(pkt); let pkt = Box::from_raw(pkt);
let _ = Box::from_raw(pkt.data as *mut u8);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment