summaryrefslogtreecommitdiffstats
path: root/src/plugins/directshow/camera
diff options
context:
space:
mode:
authorNate Weibley <nweibley@gmail.com>2018-02-17 15:51:02 -0500
committerVal Doroshchuk <valentyn.doroshchuk@qt.io>2019-07-05 14:39:43 +0200
commit1b70bbed49d12af86851a505a5aa5428b9e0c567 (patch)
tree723cc6e823b8e1980742ea50e57e3b3e1f7a500f /src/plugins/directshow/camera
parent8756a20821305eabb6026400e6d3cdc79df1690d (diff)
Fix GetFrameRateList checks and memory leak
GetFrameRateList passes an unmanaged pointer to the caller which must be manually freed with CoTaskMemFree. Additionally the Chromium project notes that some drivers cause quirky return values which we would not catch without stricter checks. See: https://chromium.googlesource.com/chromium/src/media/+/8cc93abd7339eeb9b7c2a12cca07b3dc245b2139/video/capture/win/video_capture_device_win.cc#484 Change-Id: I6aa4a6ea1ac0241e585e98cf9ff63240bacd3956 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/directshow/camera')
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index 5ab9f67d8..a237811ae 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -1137,8 +1137,8 @@ void DSCameraSession::updateSourceCapabilities()
long listSize = 0;
LONGLONG *frameRates = 0;
SIZE size = { resolution.width(), resolution.height() };
- if (SUCCEEDED(pVideoControl->GetFrameRateList(pPin, iIndex, size,
- &listSize, &frameRates))) {
+ hr = pVideoControl->GetFrameRateList(pPin, iIndex, size, &listSize, &frameRates);
+ if (hr == S_OK && listSize > 0 && frameRates) {
for (long i = 0; i < listSize; ++i) {
qreal fr = qreal(10000000) / frameRates[i];
frameRateRanges.append(QCamera::FrameRateRange(fr, fr));
@@ -1147,6 +1147,8 @@ void DSCameraSession::updateSourceCapabilities()
// Make sure higher frame rates come first
std::sort(frameRateRanges.begin(), frameRateRanges.end(), qt_frameRateRangeGreaterThan);
}
+
+ CoTaskMemFree(frameRates);
pPin->Release();
}
}