filter::graph::Graph::input()/output() bugs,cause memory leak and does not support more than 2 inputs/outputs
damaitou opened this issue · 0 comments
damaitou commented
I paste the output() code here and add comment to the line which bug occurs. same question to the input() code.
pub fn output(mut self, name: &str, pad: usize) -> Result<Self, Error> {
unsafe {
let mut context = self.graph.get(name).ok_or(Error::InvalidData)?;
let output = avfilter_inout_alloc();
if output.is_null() {
panic!("out of memory");
}
let name = CString::new(name).unwrap();
(*output).name = av_strdup(name.as_ptr());
(*output).filter_ctx = context.as_mut_ptr();
(*output).pad_idx = pad as c_int;
(*output).next = ptr::null_mut();
if self.outputs.is_null() {
self.outputs = output;
} else {
(*self.outputs).next = output; //BUG here. output should be append to the tail of the linklist, should not append to the head. this cause memory leaks and does not support more than 2 outputs.
}
}
Ok(self)
}