summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-04-06 15:32:17 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-05-04 04:39:19 +0000
commit6a0c5b791876c79ddbcc06cd20c2d16572f3e00d (patch)
tree55336f96dbe0985f17b8c5ae7c6e92faf44b73ec
parent189291bd7ab85b5e8a1e0af32f01d14e7722e466 (diff)
Fix leak if loader error is seen first
For some reason the proxied_loader_receiver can still be bound in this case. Change-Id: If0bbe181eca5de41e82eebaced412361fe12fb40 Reviewed-by: Michal Klocek <michal.klocek@qt.io> (cherry picked from commit ffb831d9896dcdd3d469fdbeee407d96d631dbda) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/core/net/proxying_url_loader_factory_qt.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/net/proxying_url_loader_factory_qt.cpp b/src/core/net/proxying_url_loader_factory_qt.cpp
index a5b732a4f..39630cf2d 100644
--- a/src/core/net/proxying_url_loader_factory_qt.cpp
+++ b/src/core/net/proxying_url_loader_factory_qt.cpp
@@ -175,6 +175,8 @@ private:
bool local_access_ = false;
bool remote_access_ = true;
+ bool loader_error_seen_ = false;
+
// If the |target_loader_| called OnComplete with an error this stores it.
// That way the destructor can send it to OnReceivedError if safe browsing
// error didn't occur.
@@ -392,6 +394,7 @@ void InterceptedRequest::ContinueAfterIntercept()
}
if (!target_loader_ && target_factory_) {
+ loader_error_seen_ = false;
target_factory_->CreateLoaderAndStart(target_loader_.BindNewPipeAndPassReceiver(), request_id_,
options_, request_, proxied_client_receiver_.BindNewPipeAndPassRemote(),
traffic_annotation_);
@@ -497,6 +500,8 @@ void InterceptedRequest::OnURLLoaderError(uint32_t custom_reason, const std::str
// If CallOnComplete was already called, then this object is ready to be deleted.
if (!target_client_)
delete this;
+ else
+ loader_error_seen_ = true;
}
void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus &status, bool wait_for_loader_error)
@@ -510,7 +515,7 @@ void InterceptedRequest::CallOnComplete(const network::URLLoaderCompletionStatus
if (target_client_)
target_client_->OnComplete(status);
- if (proxied_loader_receiver_.is_bound() && wait_for_loader_error) {
+ if (proxied_loader_receiver_.is_bound() && wait_for_loader_error && !loader_error_seen_) {
// Since the original client is gone no need to continue loading the
// request.
proxied_client_receiver_.reset();