Commit ed762709 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

don't trigger UB on vector::front

"Calling front on an empty container is undefined." so instead return
with empty frame data. since I can't reproduce the crash I'm having high
hopes that it should be fixed by simply not running the memcpy

probably fixes https://errors-eval.kde.org/organizations/kde/issues/180
parent 5c83dcdb
Pipeline #255297 passed with stage
in 2 minutes and 16 seconds
......@@ -417,8 +417,12 @@ void MovieDecoder::getScaledVideoFrame(int scaledSize, bool maintainAspectRatio,
videoFrame.lineSize = m_pFrame->linesize[0];
videoFrame.frameData.clear();
videoFrame.frameData.resize(videoFrame.lineSize * videoFrame.height);
memcpy((&(videoFrame.frameData.front())), m_pFrame->data[0], videoFrame.lineSize * videoFrame.height);
const auto frameSize = videoFrame.lineSize * videoFrame.height;
if (frameSize < 1) {
return; // calling front() on an empty vector is undefined behavior; return empty frame data instead
}
videoFrame.frameData.resize(frameSize);
memcpy((&(videoFrame.frameData.front())), m_pFrame->data[0], frameSize);
}
void MovieDecoder::convertAndScaleFrame(AVPixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight)
......
Supports Markdown
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