Bug 1183781 - Fix leak in nsHostResolver r=sworkman

This commit is contained in:
Valentin Gosu 2015-07-18 00:22:45 +02:00
parent d2ab629a20
commit f86dd2a004

View File

@ -471,6 +471,15 @@ HostDB_ClearEntry(PLDHashTable *table,
}
}
#endif
{
MutexAutoLock lock(he->rec->addr_info_lock);
if (he->rec->addr_info) {
delete hr->addr_info;
he->rec->addr_info = nullptr;
}
}
NS_RELEASE(he->rec);
}
@ -853,8 +862,12 @@ nsHostResolver::ResolveHost(const char *host,
LOG((" Trying AF_UNSPEC entry for host [%s%s%s] af: %s.\n",
LOG_HOST(host, netInterface),
(af == PR_AF_INET) ? "AF_INET" : "AF_INET6"));
he->rec->addr_info = nullptr;
// Ensure existing `addr_info` in `he` is cleared before
// copying from `unSpecHe`.
if (he->rec->addr_info) {
delete he->rec->addr_info;
he->rec->addr_info = nullptr;
}
if (unspecHe->rec->negative) {
he->rec->negative = unspecHe->rec->negative;
he->rec->CopyExpirationTimesAndFlagsFrom(unspecHe->rec);