Skip to content

Commit ba5082b

Browse files
committed
Add interface check for userAgent in SettingsComponent
1 parent eba8ee2 commit ba5082b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

SampleApps/WebView2APISample/SettingsComponent.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ SettingsComponent::SettingsComponent(
4242
old->m_settings.try_query<ICoreWebView2ExperimentalSettings>();
4343
wil::com_ptr<ICoreWebView2ExperimentalSettings> experimental_settings_new;
4444
experimental_settings_new = m_settings.try_query<ICoreWebView2ExperimentalSettings>();
45-
LPWSTR user_agent;
46-
CHECK_FAILURE(experimental_settings_old->get_UserAgent(&user_agent));
47-
CHECK_FAILURE(experimental_settings_new->put_UserAgent(user_agent));
45+
if (experimental_settings_old && experimental_settings_new)
46+
{
47+
LPWSTR user_agent;
48+
CHECK_FAILURE(experimental_settings_old->get_UserAgent(&user_agent));
49+
CHECK_FAILURE(experimental_settings_new->put_UserAgent(user_agent));
50+
}
4851
SetBlockImages(old->m_blockImages);
4952
SetReplaceImages(old->m_replaceImages);
5053
m_deferScriptDialogs = old->m_deferScriptDialogs;

0 commit comments

Comments
 (0)