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


git-svn-id: svn://10.0.0.236/trunk@116924 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
alecf%netscape.com
2002-03-20 00:25:21 +00:00
parent d23954672d
commit afdf75f460
2 changed files with 12 additions and 17 deletions

View File

@@ -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