NALU↔RBSP conversion functions: don't leak memory

mm_mem_io_c allocates a buffer. Calling get_and_lock_buffer() on it will
return the buffer and disassociate it from mm_mem_io_c, meaning the
mm_mem_io_c instance won't free it itself. Then cloning from this
already disassociated buffer is a superfluous memory copy for one and it
fails to free the buffer causing a massive memory leak.
This commit is contained in:
Moritz Bunkus 2015-12-29 19:24:18 +01:00
parent 1d419d5655
commit 2aeddd12f3

View File

@ -35,7 +35,7 @@ nalu_to_rbsp(memory_cptr const &buffer) {
d.write_uint8(b[pos]);
}
return memory_c::clone(d.get_and_lock_buffer(), d.getFilePointer());
return std::make_shared<memory_c>(d.get_and_lock_buffer(), d.getFilePointer(), true);
}
memory_cptr
@ -58,7 +58,7 @@ rbsp_to_nalu(memory_cptr const &buffer) {
d.write_uint8(b[pos]);
}
return memory_c::clone(d.get_and_lock_buffer(), d.getFilePointer());
return std::make_shared<memory_c>(d.get_and_lock_buffer(), d.getFilePointer(), true);
}
}