Skip to content

Commit

Permalink
Merge pull request #947 from /issues/2213
Browse files Browse the repository at this point in the history
correctly delete fetchers
  • Loading branch information
bbondy committed Nov 22, 2018
1 parent c4975cc commit c8e55c3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,11 @@ void RewardsServiceImpl::Shutdown() {
}
}

for (const auto fetcher : fetchers_) {
delete fetcher.first;
}
fetchers_.clear();

ledger_.reset();
RewardsService::Shutdown();
}
Expand Down Expand Up @@ -868,11 +872,14 @@ std::unique_ptr<ledger::LedgerURLLoader> RewardsServiceImpl::LoadURL(

void RewardsServiceImpl::OnURLFetchComplete(
const net::URLFetcher* source) {
if (fetchers_.find(source) == fetchers_.end())
if (fetchers_.find(source) == fetchers_.end()) {
delete source;
return;
}

auto callback = fetchers_[source];
fetchers_.erase(source);

int response_code = source->GetResponseCode();
std::string body;
std::map<std::string, std::string> headers;
Expand All @@ -893,6 +900,8 @@ void RewardsServiceImpl::OnURLFetchComplete(
source->GetResponseAsString(&body);
}

delete source;

callback.Run(response_code, body, headers);
}

Expand Down

0 comments on commit c8e55c3

Please sign in to comment.