From 58df0ada6e79ff7d4e6eb717e046d0f3f6aa880c Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Tue, 30 Oct 2018 16:31:34 +0100 Subject: [PATCH] Add guards to VideoCaptureDS::Init for when pins are null GetInputPin() and GetOutputPin() do not guarantee returning non-null pins. Should either of them return null during Init() we're better off returning an error than allowing unsafe behavior further ahead. Bug: webrtc:9941 Change-Id: I25858f0555334b4ef99801f83454931384695bf6 Reviewed-on: https://webrtc-review.googlesource.com/c/108603 Reviewed-by: Per Kjellander Commit-Queue: Per Kjellander Cr-Commit-Position: refs/heads/master@{#25475} --- modules/video_capture/windows/video_capture_ds.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/video_capture/windows/video_capture_ds.cc b/modules/video_capture/windows/video_capture_ds.cc index 778fd8761a..ea377a3b05 100644 --- a/modules/video_capture/windows/video_capture_ds.cc +++ b/modules/video_capture/windows/video_capture_ds.cc @@ -95,6 +95,10 @@ int32_t VideoCaptureDS::Init(const char* deviceUniqueIdUTF8) { } _outputCapturePin = GetOutputPin(_captureFilter, PIN_CATEGORY_CAPTURE); + if (!_outputCapturePin) { + RTC_LOG(LS_INFO) << "Failed to get output capture pin"; + return -1; + } // Create the sink filte used for receiving Captured frames. _sinkFilter = new CaptureSinkFilter(SINK_FILTER_NAME, NULL, &hr, *this); @@ -109,7 +113,12 @@ int32_t VideoCaptureDS::Init(const char* deviceUniqueIdUTF8) { RTC_LOG(LS_INFO) << "Failed to add the send filter to the graph."; return -1; } + _inputSendPin = GetInputPin(_sinkFilter); + if (!_inputSendPin) { + RTC_LOG(LS_INFO) << "Failed to get input send pin"; + return -1; + } // Temporary connect here. // This is done so that no one else can use the capture device.