зеркало из https://github.com/mozilla/gecko-dev.git
Bug 183871
Crash on "Show hidden files and directories" [@ nsFileView::SetDirectory(nsIFile*) ] fix: don't let files be initialized with relative paths. also fix the directory service to not do that. r=dougt sr=bzbarsky
This commit is contained in:
Родитель
d4411bb66c
Коммит
f1d3381adb
|
@ -252,31 +252,29 @@ nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile)
|
|||
|
||||
if (moz5)
|
||||
{
|
||||
localFile->InitWithNativePath(nsDependentCString(moz5));
|
||||
localFile->Normalize();
|
||||
*aFile = localFile;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(DEBUG)
|
||||
static PRBool firstWarning = PR_TRUE;
|
||||
|
||||
if(firstWarning) {
|
||||
// Warn that MOZILLA_FIVE_HOME not set, once.
|
||||
printf("Warning: MOZILLA_FIVE_HOME not set.\n");
|
||||
firstWarning = PR_FALSE;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
// Fall back to current directory.
|
||||
if (getcwd(buf, sizeof(buf)))
|
||||
{
|
||||
if (realpath(moz5, buf)) {
|
||||
localFile->InitWithNativePath(nsDependentCString(buf));
|
||||
*aFile = localFile;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
#if defined(DEBUG)
|
||||
static PRBool firstWarning = PR_TRUE;
|
||||
|
||||
if(!moz5 && firstWarning) {
|
||||
// Warn that MOZILLA_FIVE_HOME not set, once.
|
||||
printf("Warning: MOZILLA_FIVE_HOME not set.\n");
|
||||
firstWarning = PR_FALSE;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
// Fall back to current directory.
|
||||
if (getcwd(buf, sizeof(buf)))
|
||||
{
|
||||
localFile->InitWithNativePath(nsDependentCString(buf));
|
||||
*aFile = localFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#elif defined(XP_OS2)
|
||||
PPIB ppib;
|
||||
|
|
|
@ -270,6 +270,9 @@ nsLocalFile::InitWithNativePath(const nsACString &filePath)
|
|||
}
|
||||
|
||||
mPath = homePath + Substring(filePath, 1, filePath.Length() - 1);
|
||||
} else if (filePath.IsEmpty() || filePath.First() != '/') {
|
||||
NS_ERROR("Relative paths not allowed");
|
||||
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
|
||||
} else {
|
||||
mPath = filePath;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче