зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
c78b60d6ba
Коммит
9d8285413f
|
@ -621,21 +621,18 @@ nsLocalFile::ResolveAndStat(PRBool resolveTerminal)
|
|||
NS_IMETHODIMP
|
||||
nsLocalFile::Clone(nsIFile **file)
|
||||
{
|
||||
nsresult rv;
|
||||
char * aFilePath;
|
||||
GetPath(&aFilePath);
|
||||
*file = nsnull;
|
||||
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsLocalFile *localFile = new nsLocalFile(*this);
|
||||
if (localFile == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = NS_NewLocalFile(aFilePath, mFollowSymlinks, getter_AddRefs(localFile));
|
||||
nsMemory::Free(aFilePath);
|
||||
localFile->mRefCnt = 0;
|
||||
|
||||
if (NS_SUCCEEDED(rv) && localFile)
|
||||
{
|
||||
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)file);
|
||||
}
|
||||
*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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче