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
Branches
Tags
No related merge requests found
...@@ -134,11 +134,15 @@ VideoProvider::captureRawVideoFrame(const QString& id) ...@@ -134,11 +134,15 @@ VideoProvider::captureRawVideoFrame(const QString& id)
if (videoFrame.map(QVideoFrame::ReadOnly)) { if (videoFrame.map(QVideoFrame::ReadOnly)) {
auto imageFormat = QVideoFrameFormat::imageFormatFromPixelFormat( auto imageFormat = QVideoFrameFormat::imageFormatFromPixelFormat(
QVideoFrameFormat::Format_RGBA8888); QVideoFrameFormat::Format_RGBA8888);
img = QImage(videoFrame.bits(0), // Create a temporary QImage that wraps the video frame data
videoFrame.width(), QImage tempImage(videoFrame.bits(0),
videoFrame.height(), videoFrame.width(),
videoFrame.bytesPerLine(0), videoFrame.height(),
imageFormat); videoFrame.bytesPerLine(0),
imageFormat);
// Make a deep copy so that the image owns its data
img = tempImage.copy();
videoFrame.unmap();
} }
} }
return img; return img;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment