Skip to content

Commit 267dd7f

Browse files
author
Michal Klocek
committed
Fix race condition in ResourceDispatcherHostLoginDelegateQt
Do no access m_request from ui thread. The auth request can get cancelled, this can happen for example when a new navigation interrupts the current one. Fixes: QTBUG-71128 Change-Id: I140b1a164294342bad13a76342c1f642ba0960c8 Reviewed-by: Kai Koehne <[email protected]>
1 parent bdb2c84 commit 267dd7f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ namespace QtWebEngineCore {
5959
ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
6060
: m_authInfo(authInfo)
6161
, m_request(request)
62+
, m_url(http://github.com/request->%3Cspan%20class=%22pl-en%22%3Eurl%3C/span%3E())
6263
{
6364
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
6465
const content::ResourceRequestInfo *requestInfo = content::ResourceRequestInfo::ForRequest(request);
@@ -81,11 +82,12 @@ ResourceDispatcherHostLoginDelegateQt::~ResourceDispatcherHostLoginDelegateQt()
8182
void ResourceDispatcherHostLoginDelegateQt::OnRequestCancelled()
8283
{
8384
destroy();
85+
// TODO: this should close native dialog, since page can be navigated somewhere else
8486
}
8587

8688
QUrl ResourceDispatcherHostLoginDelegateQt::url() const
8789
{
88-
return toQt(m_request->url());
90+
return toQt(m_url);
8991
}
9092

9193
QString ResourceDispatcherHostLoginDelegateQt::realm() const
@@ -135,7 +137,7 @@ void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, co
135137
void ResourceDispatcherHostLoginDelegateQt::destroy()
136138
{
137139
m_dialogController.reset();
138-
m_request = 0;
140+
m_request = nullptr;
139141
}
140142

141143
static void LaunchURL(const GURL& url, int render_process_id,

src/core/renderer_host/resource_dispatcher_host_delegate_qt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ResourceDispatcherHostLoginDelegateQt : public content::ResourceDispatcher
7373
// The request that wants login data.
7474
// Must only be accessed on the IO thread.
7575
net::URLRequest *m_request;
76-
76+
GURL m_url;
7777
// This member is used to keep authentication dialog controller alive until
7878
// authorization is sent or cancelled.
7979
QSharedPointer<AuthenticationDialogController> m_dialogController;

0 commit comments

Comments
 (0)