fix for bug 124497 - leaking nsLocalFile objects - the copy constructor was copying the refcount to the new object

so the new object would always leak
r=dbradley, sr=darin, a=asa
This commit is contained in:
alecf%netscape.com 2002-03-16 05:30:15 +00:00
parent 523eb4e6a8
commit f9de1f9460

View File

@ -654,10 +654,14 @@ nsLocalFile::Clone(nsIFile **file)
*file = nsnull;
// Just copy-construct ourselves
nsCOMPtr<nsILocalFile> localFile = new nsLocalFile(*this);
nsLocalFile *localFile = new nsLocalFile(*this);
if (localFile == NULL)
return NS_ERROR_OUT_OF_MEMORY;
return NS_ERROR_OUT_OF_MEMORY;
// don't forget to re-initialize mRefCnt
// or the new object will have the old refcnt
localFile->mRefCnt = 0;
*file = localFile;
NS_ADDREF(*file);