fix possible memory leak when adding mime info objects to mime cache.

Bug 109130, r=law, sr=rpotts
This commit is contained in:
bzbarsky%mit.edu 2001-11-27 21:21:34 +00:00
parent 1a03dbbd6b
commit ad32eded51

View File

@ -1645,6 +1645,8 @@ nsresult nsExternalHelperAppService::AddMimeInfoToCache(nsIMIMEInfo * aMIMEInfo)
nsCStringKey key(mimeType);
oldInfo = (nsIMIMEInfo*)mMimeInfoCache->Put(&key, aMIMEInfo);
// release the old info to prevent a leak
NS_IF_RELEASE(oldInfo);
// add a reference for the hash table entry....
NS_ADDREF(aMIMEInfo);
}
@ -1659,6 +1661,7 @@ nsresult nsExternalHelperAppService::AddMimeInfoToCache(nsIMIMEInfo * aMIMEInfo)
{
nsCStringKey key(extensions[i]);
oldInfo = (nsIMIMEInfo*) mMimeInfoCache->Put(&key, aMIMEInfo);
NS_IF_RELEASE(oldInfo); // release the old info to prevent a leak
NS_ADDREF(aMIMEInfo); // addref this new entry in the table
nsMemory::Free( extensions[i] );
}