Skip to content
Snippets Groups Projects
Commit 37f29c98 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Adrien Béraud
Browse files

videoprovider: fix possible use-after-free on Windows

This creates a deep copy QImage of the video frame during the call to
captureRawVideoFrame.

Gitlab: #1916
Change-Id: Ifa3ba8950ddd1fb13892665d011733fd45c88d12
parent 1bfacdbb
No related branches found
No related tags found
No related merge requests found
......@@ -134,11 +134,15 @@ VideoProvider::captureRawVideoFrame(const QString& id)
if (videoFrame.map(QVideoFrame::ReadOnly)) {
auto imageFormat = QVideoFrameFormat::imageFormatFromPixelFormat(
QVideoFrameFormat::Format_RGBA8888);
img = QImage(videoFrame.bits(0),
videoFrame.width(),
videoFrame.height(),
videoFrame.bytesPerLine(0),
imageFormat);
// Create a temporary QImage that wraps the video frame data
QImage tempImage(videoFrame.bits(0),
videoFrame.width(),
videoFrame.height(),
videoFrame.bytesPerLine(0),
imageFormat);
// Make a deep copy so that the image owns its data
img = tempImage.copy();
videoFrame.unmap();
}
}
return img;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment