diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index ba203936b80..93336ac5617 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -240,16 +240,17 @@ nsLocalFile::Clone(nsIFile **file) { CHECK_mPath(); NS_ENSURE_ARG(file); - *file = nsnull; - - // Just copy-construct ourselves - nsCOMPtr localFile = new nsLocalFile(*this); + + nsCOMPtr localFile = new nsLocalFile(); if (!localFile) - return NS_ERROR_OUT_OF_MEMORY; + return NS_ERROR_OUT_OF_MEMORY; + + nsresult rv = localFile->InitWithPath(mPath); + if (NS_FAILED(rv)) + return rv; *file = localFile; NS_ADDREF(*file); - return NS_OK; } diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index c7cf651613c..21f96f910d7 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -650,18 +650,18 @@ nsLocalFile::ResolveAndStat(PRBool resolveTerminal) NS_IMETHODIMP nsLocalFile::Clone(nsIFile **file) { - NS_ENSURE_ARG(file); - *file = nsnull; + nsresult rv; - // Just copy-construct ourselves - nsCOMPtr localFile = new nsLocalFile(*this); - if (localFile == NULL) - return NS_ERROR_OUT_OF_MEMORY; + nsCOMPtr localFile; - *file = localFile; - NS_ADDREF(*file); - - return NS_OK; + rv = NS_NewLocalFile(mWorkingPath.get(), mFollowSymlinks, getter_AddRefs(localFile)); + + if (NS_SUCCEEDED(rv) && localFile) + { + return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)file); + } + + return rv; } NS_IMETHODIMP