From 80c221df0de81c2ca00cd3dcb652c44b2bc1e763 Mon Sep 17 00:00:00 2001 From: Pranjal Jumde Date: Thu, 18 Apr 2019 01:06:47 -0700 Subject: [PATCH] Issue 4152: findFirstPartyHosts returns a value on the heap. Delete to avoid leaks. auditors: @nejczdovc, @bsclifton --- .../brave_shields/browser/tracking_protection_service.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/brave_shields/browser/tracking_protection_service.cc b/components/brave_shields/browser/tracking_protection_service.cc index 7006da0986d0..03bb6fcce287 100644 --- a/components/brave_shields/browser/tracking_protection_service.cc +++ b/components/brave_shields/browser/tracking_protection_service.cc @@ -320,10 +320,10 @@ std::vector TrackingProtectionService::GetThirdPartyHosts( } } - std::string thirdPartyHosts = + char* thirdPartyHosts = tracking_protection_client_->findFirstPartyHosts(base_host.c_str()); std::vector hosts; - if (!thirdPartyHosts.empty()) { + if (nullptr != thirdPartyHosts) { std::string strThirdPartyHosts = thirdPartyHosts; size_t iPos = strThirdPartyHosts.find(","); while (iPos != std::string::npos) { @@ -335,6 +335,7 @@ std::vector TrackingProtectionService::GetThirdPartyHosts( if (0 != strThirdPartyHosts.length()) { hosts.push_back(strThirdPartyHosts); } + delete []thirdPartyHosts; } {