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 <tommi@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28408}
This commit is contained in:
Julien Isorce 2019-06-25 16:05:00 -07:00 committed by Commit Bot
parent 9407776aa2
commit 71809c67ce
2 changed files with 4 additions and 5 deletions

View File

@ -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;
}

View File

@ -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