diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-12 16:55:31 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-12 16:55:31 +0000 |
commit | 8ec8c2999285bd7c83de321a8859fe98f8a2cde4 (patch) | |
tree | 491bf62d9ab14a52bdd4d0a6807052e705a0a806 /net | |
parent | 017a7a11d6fa3aa239dd4997f260c819897b7e8a (diff) | |
download | chromium_src-8ec8c2999285bd7c83de321a8859fe98f8a2cde4.zip chromium_src-8ec8c2999285bd7c83de321a8859fe98f8a2cde4.tar.gz chromium_src-8ec8c2999285bd7c83de321a8859fe98f8a2cde4.tar.bz2 |
linux: avoid closing uninitialized resolver
When _res is uninitialized, res_nclose may end up closing fd 0.
Test whether it's initialized before closing.
Patch by Jim Deng <jdeng@google.com>.
TEST=chrome without a net connection doesn't crash on startup
Review URL: http://codereview.chromium.org/3717002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62288 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/host_resolver_proc.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc index d235ce9..c2235c3 100644 --- a/net/base/host_resolver_proc.cc +++ b/net/base/host_resolver_proc.cc @@ -202,7 +202,11 @@ int SystemHostResolverProc(const std::string& host, // If we fail, re-initialise the resolver just in case there have been any // changes to /etc/resolv.conf and retry. See http://crbug.com/11380 for info. if (err && DnsReloadTimerHasExpired()) { - res_nclose(&_res); + // When there's no network connection, _res may not be initialized by + // getaddrinfo. Therefore, we call res_nclose only when there are ns + // entries. + if (_res.nscount > 0) + res_nclose(&_res); if (!res_ninit(&_res)) should_retry = true; } |