Check whether on_screen is null before performing CFBooleanGetValue()

A crash may randomly happen in IsWindowMinimized(), the potential reason is that
|on_screen| is not retrieved from |window| with kCGWindowIsOnScreen property. So
add a == NULL check before executing CFBooleanGetValue().

Bug: chromium:758554
Change-Id: I25ad1ddbb21ec049ef237e55a8d25156bcd982c7
Reviewed-on: https://chromium-review.googlesource.com/634043
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Commit-Queue: Zijie He <zijiehe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#19527}
This commit is contained in:
Zijie He 2017-08-25 10:39:23 -07:00 committed by Commit Bot
parent f3b151bea6
commit c1f691dff2

View File

@ -141,7 +141,7 @@ bool IsWindowFullScreen(
bool IsWindowMinimized(CFDictionaryRef window) {
CFBooleanRef on_screen = reinterpret_cast<CFBooleanRef>(
CFDictionaryGetValue(window, kCGWindowIsOnscreen));
return !CFBooleanGetValue(on_screen);
return on_screen != NULL && !CFBooleanGetValue(on_screen);
}
// Returns true if the window is minimized.