Commit bcdfbeb3 authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

UpdateState dereferences a null BSTR when the next_version is empty.

The issue here is that the nullptr returned from the function
creates an error path which the caller must handle, or else the
code crashes.

In the updater, a null version and an empty version mean the same
thing, therefore, this CL replaces the nullptr with "".

There is an unrelated change to reduce the verbosity  of logging
for a repeating callback.


Bug: 1128195
Change-Id: I94a8853306edf7bb6eaddfe5ac0807ccaf9e0a2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2411551
Auto-Submit: Sorin Jianu <sorin@chromium.org>
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806990}
parent c472c70c
...@@ -39,12 +39,11 @@ STDMETHODIMP UpdateStateImpl::get_appId(BSTR* app_id) { ...@@ -39,12 +39,11 @@ STDMETHODIMP UpdateStateImpl::get_appId(BSTR* app_id) {
STDMETHODIMP UpdateStateImpl::get_nextVersion(BSTR* next_version) { STDMETHODIMP UpdateStateImpl::get_nextVersion(BSTR* next_version) {
DCHECK(next_version); DCHECK(next_version);
*next_version = *next_version =
update_state_.next_version.IsValid() base::win::ScopedBstr(
? base::win::ScopedBstr( update_state_.next_version.IsValid()
base::UTF8ToWide(update_state_.next_version.GetString())) ? base::UTF8ToWide(update_state_.next_version.GetString())
.Release() : L"")
: nullptr; .Release();
return S_OK; return S_OK;
} }
...@@ -144,7 +143,7 @@ HRESULT UpdaterImpl::Update(const base::char16* app_id, ...@@ -144,7 +143,7 @@ HRESULT UpdaterImpl::Update(const base::char16* app_id,
Microsoft::WRL::Make<UpdateStateImpl>( Microsoft::WRL::Make<UpdateStateImpl>(
update_state)), update_state)),
base::BindOnce([](HRESULT hr) { base::BindOnce([](HRESULT hr) {
DVLOG(2) DVLOG(4)
<< "IUpdaterObserver::OnStateChange returned " << "IUpdaterObserver::OnStateChange returned "
<< std::hex << hr; << std::hex << hr;
})); }));
......
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