Bug 426060: handle the possibility that both mHostRecord->addr_info and mHostRecord->addr are null if the old mHostRecord->addr_info exired and our attempt to reresolve it failed. r=jst, sr=cbiesinger blocking1.9+ Modified Files: nsDNSService2.cpp nsHostResolver.cpp

This commit is contained in:
wtc@google.com 2008-04-08 17:42:52 -07:00
parent 1772193496
commit d68f1edbec
2 changed files with 9 additions and 2 deletions

View File

@ -137,7 +137,12 @@ nsDNSRecord::GetNextAddr(PRUint16 port, PRNetAddr *addr)
}
else {
PR_Unlock(mHostRecord->addr_info_lock);
NS_ASSERTION(mHostRecord->addr, "no addr");
if (!mHostRecord->addr) {
// Both mHostRecord->addr_info and mHostRecord->addr are null.
// This can happen if mHostRecord->addr_info expired and the
// attempt to reresolve it failed.
return NS_ERROR_NOT_AVAILABLE;
}
memcpy(addr, mHostRecord->addr, sizeof(PRNetAddr));
// set given port
port = PR_htons(port);

View File

@ -637,7 +637,9 @@ nsHostResolver::OnLookupComplete(nsHostRecord *rec, nsresult status, PRAddrInfo
PR_Unlock(rec->addr_info_lock);
if (old_addr_info)
PR_FreeAddrInfo(old_addr_info);
rec->expiration = NowInMinutes() + mMaxCacheLifetime;
rec->expiration = NowInMinutes();
if (result)
rec->expiration += mMaxCacheLifetime;
rec->resolving = PR_FALSE;
if (rec->addr_info && !mShutdown) {