Commit 77a09a6b authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato
Browse files

crav1e: Do not use libc::strdup in status_to_str

MSVC would not find it when building a shared library.
Incidentally also fix a use after free.
parent bbafb67e
......@@ -383,9 +383,16 @@ pub unsafe extern "C" fn rav1e_last_status(ctx: *const Context) -> EncoderStatus
pub unsafe extern "C" fn rav1e_status_to_str(status: EncoderStatus) -> *mut c_char {
let status = format!("{:?}", status);
let cptr = CString::new(status).unwrap().as_ptr();
let cbuf = CString::new(status).unwrap();
let len = cbuf.as_bytes_with_nul().len();
let ret = libc::malloc(len);
if !ret.is_null() {
let cptr = cbuf.as_ptr() as *const libc::c_void;
libc::memcpy(ret, cptr, len);
ret as *mut c_char
/// Receive encoded data
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