From 2aeddd12f30ead2378d90339a0727f1e6d708d32 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 29 Dec 2015 19:24:18 +0100 Subject: [PATCH] =?UTF-8?q?NALU=E2=86=94RBSP=20conversion=20functions:=20d?= =?UTF-8?q?on't=20leak=20memory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/common/mpeg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/mpeg.cpp b/src/common/mpeg.cpp index 7263a6734..1bab3065b 100644 --- a/src/common/mpeg.cpp +++ b/src/common/mpeg.cpp @@ -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(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(d.get_and_lock_buffer(), d.getFilePointer(), true); } }