Commit 9d10a275 authored by Sunny Sachanandani's avatar Sunny Sachanandani Committed by Commit Bot

gpu: Fix uninitialized memory in SwapChainPresenter

|swap_chain_format_| should be initialized to prevent crashes when
calling strlen() on the return value DxgiFormatToString().  Initializing
to BGRA matches the behavior prior to adding |swap_chain_format_|.  Also
guard against such crashes by returning a valid string instead of
nullptr from DxgiFormatToString().

Bug: 1129031
Change-Id: I113bca2b7a5899dc270f97089f94c6222b2a71cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414654Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807637}
parent 5c917c15
...@@ -133,7 +133,7 @@ const char* DxgiFormatToString(DXGI_FORMAT format) { ...@@ -133,7 +133,7 @@ const char* DxgiFormatToString(DXGI_FORMAT format) {
return "NV12"; return "NV12";
default: default:
NOTREACHED(); NOTREACHED();
return nullptr; return "UNKNOWN";
} }
} }
......
...@@ -173,7 +173,7 @@ class SwapChainPresenter : public base::PowerObserver { ...@@ -173,7 +173,7 @@ class SwapChainPresenter : public base::PowerObserver {
gfx::Size swap_chain_size_; gfx::Size swap_chain_size_;
// Current swap chain format. // Current swap chain format.
DXGI_FORMAT swap_chain_format_; DXGI_FORMAT swap_chain_format_ = DXGI_FORMAT_B8G8R8A8_UNORM;
// Whether the swap chain was reallocated, and next present will be the first. // Whether the swap chain was reallocated, and next present will be the first.
bool first_present_ = false; bool first_present_ = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment