Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Unified Diff: net/proxy/proxy_resolver_v8_tracing.cc

Issue 12088090: Fix a memory error in ProxyResolverV8Tracing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove a bad DCHECK Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/proxy/proxy_resolver_v8_tracing_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_resolver_v8_tracing.cc
diff --git a/net/proxy/proxy_resolver_v8_tracing.cc b/net/proxy/proxy_resolver_v8_tracing.cc
index ea3257751338966bec79aeaccfa1354567ca72e3..243a73efc54828f5ab678c564f9fd7fff6757e6d 100644
--- a/net/proxy/proxy_resolver_v8_tracing.cc
+++ b/net/proxy/proxy_resolver_v8_tracing.cc
@@ -659,22 +659,35 @@ void ProxyResolverV8Tracing::Job::DoDnsOperation(
if (cancelled_.IsSet())
return;
+ HostResolver::RequestHandle dns_request = NULL;
int result = host_resolver()->Resolve(
MakeDnsRequestInfo(host, op),
&pending_dns_addresses_,
base::Bind(&Job::OnDnsOperationComplete, this),
- &pending_dns_,
+ &dns_request,
bound_net_log_);
bool completed_synchronously = result != ERR_IO_PENDING;
+ // Check if the request was cancelled as a side-effect of calling into the
+ // HostResolver. This isn't the ordinary execution flow, however it is
+ // exercised by unit-tests.
+ if (cancelled_.IsSet()) {
+ if (!completed_synchronously)
+ host_resolver()->CancelRequest(dns_request);
+ return;
+ }
+
+ if (!completed_synchronously) {
+ DCHECK(dns_request);
+ pending_dns_ = dns_request;
+ }
+
if (!blocking_dns_) {
// Check if the DNS result can be serviced directly from the cache.
// (The worker thread is blocked waiting for this information).
- if (completed_synchronously) {
+ if (completed_synchronously)
SaveDnsToLocalCache(host, op, result, pending_dns_addresses_);
- pending_dns_ = NULL;
- }
// Important: Do not read/write |out_cache_hit| after signalling, since
// the memory may no longer be valid.
@@ -695,7 +708,6 @@ void ProxyResolverV8Tracing::Job::DoDnsOperation(
void ProxyResolverV8Tracing::Job::OnDnsOperationComplete(int result) {
CheckIsOnOriginThread();
- DCHECK(pending_dns_);
DCHECK(!cancelled_.IsSet());
SaveDnsToLocalCache(pending_dns_host_, pending_dns_op_, result,
« no previous file with comments | « no previous file | net/proxy/proxy_resolver_v8_tracing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698