From 71809c67ce0a5cdfe368e5d7f13c3d0a14812e17 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Tue, 25 Jun 2019 16:05:00 -0700 Subject: [PATCH] WindowCapturerWin: properly check return value of GetClassName In debug mode I hit the assert so this function can return 0. So just skip the window in that case like for other desktop elements Bug: None Change-Id: I92abf2a1f450b677632f5eb4332ca218cfd850ec Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143860 Commit-Queue: Tommi Reviewed-by: Tommi Cr-Commit-Position: refs/heads/master@{#28408} --- modules/desktop_capture/win/window_capture_utils.cc | 5 ++--- modules/desktop_capture/window_capturer_win.cc | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/desktop_capture/win/window_capture_utils.cc b/modules/desktop_capture/win/window_capture_utils.cc index 845463372d..ef60c9fad6 100644 --- a/modules/desktop_capture/win/window_capture_utils.cc +++ b/modules/desktop_capture/win/window_capture_utils.cc @@ -186,9 +186,8 @@ bool WindowCaptureHelperWin::IsWindowChromeNotification(HWND hwnd) { const size_t kClassLength = 256; WCHAR class_name[kClassLength]; const int class_name_length = GetClassNameW(hwnd, class_name, kClassLength); - RTC_DCHECK(class_name_length) - << "Error retrieving the application's class name"; - if (wcsncmp(class_name, kChromeWindowClassPrefix, + if (class_name_length < 1 || + wcsncmp(class_name, kChromeWindowClassPrefix, wcsnlen_s(kChromeWindowClassPrefix, kClassLength)) != 0) { return false; } diff --git a/modules/desktop_capture/window_capturer_win.cc b/modules/desktop_capture/window_capturer_win.cc index 4ab1feb3ed..3dbec83423 100644 --- a/modules/desktop_capture/window_capturer_win.cc +++ b/modules/desktop_capture/window_capturer_win.cc @@ -54,8 +54,8 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) { const size_t kClassLength = 256; WCHAR class_name[kClassLength]; const int class_name_length = GetClassNameW(hwnd, class_name, kClassLength); - RTC_DCHECK(class_name_length) - << "Error retrieving the application's class name"; + if (class_name_length < 1) + return TRUE; // Skip Program Manager window and the Start button. This is the same logic // that's used in Win32WindowPicker in libjingle. Consider filtering other