From dc6239e350e00e2fca5a4807c6ae04fe0a58446f Mon Sep 17 00:00:00 2001 From: "ccarlen%netscape.com" Date: Tue, 3 Dec 2002 15:51:25 +0000 Subject: [PATCH] Bug 173668 - InitWithNativePath crashes if given a URL which begins with a forward slash. It happens during URI fixup. r=sdagley/sr=jaggernaut git-svn-id: svn://10.0.0.236/trunk@134695 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsLocalFileOSX.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mozilla/xpcom/io/nsLocalFileOSX.cpp b/mozilla/xpcom/io/nsLocalFileOSX.cpp index 747406ab0ad..9c2e32e8156 100644 --- a/mozilla/xpcom/io/nsLocalFileOSX.cpp +++ b/mozilla/xpcom/io/nsLocalFileOSX.cpp @@ -1220,6 +1220,13 @@ NS_IMETHODIMP nsLocalFile::InitWithNativePath(const nsACString& filePath) // On 10.2, huge paths crash CFURLGetFSRef() if (filePath.Length() > PATH_MAX) return NS_ERROR_FILE_NAME_TOO_LONG; + // And, a path with consecutive '/'s which are not between + // nodes also crashes CFURLGetFSRef(). Consecutive '/'s which + // are between actual nodes are OK. So, convert consecutive + // '/'s to a single one. + nsCAutoString fixedPath; + fixedPath.Assign(filePath); + fixedPath.ReplaceSubstring("//", "/"); mNonExtantNodes.clear(); mIdentityDirty = PR_TRUE; @@ -1227,7 +1234,7 @@ NS_IMETHODIMP nsLocalFile::InitWithNativePath(const nsACString& filePath) CFStringRef pathAsCFString; CFURLRef pathAsCFURL; - pathAsCFString = ::CFStringCreateWithCString(nsnull, PromiseFlatCString(filePath).get(), kCFStringEncodingUTF8); + pathAsCFString = ::CFStringCreateWithCString(nsnull, fixedPath.get(), kCFStringEncodingUTF8); if (!pathAsCFString) return NS_ERROR_FAILURE; pathAsCFURL = ::CFURLCreateWithFileSystemPath(nsnull, pathAsCFString, kCFURLPOSIXPathStyle, PR_FALSE);