From 77a15b38809df6084718afdc6116d036715a8b7e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 23 Mar 2015 14:09:45 +0100 Subject: Do not copy libVLC data if size absurd --- src/VLCInput.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/VLCInput.cpp') diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp index 54f71d2..4141535 100644 --- a/src/VLCInput.cpp +++ b/src/VLCInput.cpp @@ -166,17 +166,18 @@ void VLCInput::postRender_cb(uint8_t* p_pcm_buffer, size_t size) { boost::mutex::scoped_lock lock(m_queue_mutex); - if (m_current_buf.size() != size) { + if (m_current_buf.size() == size) { + size_t queue_size = m_queue.size(); + m_queue.resize(m_queue.size() + size); + std::copy(m_current_buf.begin(), m_current_buf.end(), + m_queue.begin() + queue_size); + } + else { fprintf(stderr, "Received buffer size is not equal allocated " "buffer size: %zu vs %zu\n", m_current_buf.size(), size); } - - size_t queue_size = m_queue.size(); - m_queue.resize(m_queue.size() + size); - std::copy(m_current_buf.begin(), m_current_buf.end(), - m_queue.begin() + queue_size); } ssize_t VLCInput::m_read(uint8_t* buf, size_t length) -- cgit v1.2.3