forked from mirrors/gstreamer-rs
basetransform: Don't leak any output buffer if prepare_output_buffer
fails
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1285>
This commit is contained in:
parent
eff6b4c952
commit
96c7eb9563
1 changed files with 9 additions and 0 deletions
|
@ -570,6 +570,13 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
||||||
PrepareOutputBufferSuccess::Buffer(from_glib_full(outbuf))
|
PrepareOutputBufferSuccess::Buffer(from_glib_full(outbuf))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.map_err(|err| {
|
||||||
|
if outbuf != buf as *mut _ {
|
||||||
|
drop(Option::<gst::Buffer>::from_glib_full(outbuf));
|
||||||
|
}
|
||||||
|
|
||||||
|
err
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.unwrap_or(Err(gst::FlowError::NotSupported))
|
.unwrap_or(Err(gst::FlowError::NotSupported))
|
||||||
}
|
}
|
||||||
|
@ -1140,6 +1147,8 @@ unsafe extern "C" fn base_transform_prepare_output_buffer<T: BaseTransformImpl>(
|
||||||
true => InputBuffer::Writable(gst::BufferRef::from_mut_ptr(inbuf)),
|
true => InputBuffer::Writable(gst::BufferRef::from_mut_ptr(inbuf)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
*outbuf = ptr::null_mut();
|
||||||
|
|
||||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||||
match imp.prepare_output_buffer(buffer) {
|
match imp.prepare_output_buffer(buffer) {
|
||||||
Ok(PrepareOutputBufferSuccess::InputBuffer) => {
|
Ok(PrepareOutputBufferSuccess::InputBuffer) => {
|
||||||
|
|
Loading…
Reference in a new issue