fix leak caused by nsLocalFile::Clone() where we were copying the refcnt to the new object - bug 124497

this ends up being more of a performance win than anyting on Unix and OS/2
r=mkaply, dbaron, sr=darin, a=asa
This commit is contained in:
alecf%netscape.com 2002-03-20 00:25:21 +00:00
Родитель c78b60d6ba
Коммит 9d8285413f
2 изменённых файлов: 12 добавлений и 17 удалений

Просмотреть файл

@ -621,21 +621,18 @@ nsLocalFile::ResolveAndStat(PRBool resolveTerminal)
NS_IMETHODIMP
nsLocalFile::Clone(nsIFile **file)
{
nsresult rv;
char * aFilePath;
GetPath(&aFilePath);
nsCOMPtr<nsILocalFile> localFile;
rv = NS_NewLocalFile(aFilePath, mFollowSymlinks, getter_AddRefs(localFile));
nsMemory::Free(aFilePath);
*file = nsnull;
if (NS_SUCCEEDED(rv) && localFile)
{
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)file);
}
nsLocalFile *localFile = new nsLocalFile(*this);
if (localFile == NULL)
return NS_ERROR_OUT_OF_MEMORY;
localFile->mRefCnt = 0;
*file = localFile;
NS_ADDREF(*file);
return rv;
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -243,13 +243,11 @@ nsLocalFile::Clone(nsIFile **file)
CHECK_mPath();
NS_ENSURE_ARG(file);
nsCOMPtr<nsILocalFile> localFile = new nsLocalFile();
nsLocalFile *localFile = new nsLocalFile(*this);
if (!localFile)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = localFile->InitWithPath(mPath);
if (NS_FAILED(rv))
return rv;
localFile->mRefCnt = 0;
*file = localFile;
NS_ADDREF(*file);