From d41af462fb11a4854e25a84bb0d27b8c3fdd5519 Mon Sep 17 00:00:00 2001 From: zijiehe Date: Thu, 20 Apr 2017 14:53:36 -0700 Subject: [PATCH] This change fixes a crash issue in WindowCapturerWin. The issue and fix are both obvious, WindowCapturerWin should not return Result::SUCCESS with an empty frame. This issue was original introduced into the code base in change https://codereview.webrtc.org/1988783003/. I am also considering whether we should move the previous_size_ = frame->size(); window_size_map_[window_] = previous_size_; into the true branch. But since this change needs to be merged into M58 and M59, I would prefer to keep it as small as possible. BUG=712615 Review-Url: https://codereview.webrtc.org/2835553002 Cr-Commit-Position: refs/heads/master@{#17799} --- webrtc/modules/desktop_capture/window_capturer_win.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webrtc/modules/desktop_capture/window_capturer_win.cc b/webrtc/modules/desktop_capture/window_capturer_win.cc index d796d0f4fb..0ca88cfa55 100644 --- a/webrtc/modules/desktop_capture/window_capturer_win.cc +++ b/webrtc/modules/desktop_capture/window_capturer_win.cc @@ -252,12 +252,12 @@ void WindowCapturerWin::CaptureFrame() { frame->mutable_updated_region()->SetRect( DesktopRect::MakeSize(frame->size())); - if (!result) { + if (result) { + callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); + } else { LOG(LS_ERROR) << "Both PrintWindow() and BitBlt() failed."; - frame.reset(); + callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr); } - - callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); } } // namespace