Bug 381283 - Prevent macOS startup crashes on case sensitive file systems. r=spohl

Differential Revision: https://phabricator.services.mozilla.com/D218895
This commit is contained in:
Yanis Lagha 2024-08-09 20:53:17 +00:00
Родитель 94c6346c5a
Коммит fe71af1a1c
1 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -10,10 +10,11 @@
#include "base/process_util.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Omnijar.h"
#include "nsDirectoryServiceDefs.h"
#include "nsCOMPtr.h"
#include "nsComponentManagerUtils.h"
#include "nsCOMPtr.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIFile.h"
#include "nsReadableUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
@ -84,15 +85,17 @@ bool nsMacUtilsImpl::GetAppPath(nsCString& aAppPath) {
aAppPath.Assign(*sCachedAppPath);
return true;
}
nsAutoCString appPath;
nsAutoCString appBinaryPath(
(CommandLine::ForCurrentProcess()->argv()[0]).c_str());
// Ensure binary path is lowercase to avoid crash
ToLowerCase(appBinaryPath);
// The binary path resides within the .app dir in Contents/MacOS,
// e.g., Firefox.app/Contents/MacOS/firefox. Search backwards in
// the binary path for the end of .app path.
auto pattern = "/Contents/MacOS/"_ns;
auto pattern = "/contents/macos/"_ns;
nsAutoCString::const_iterator start, end;
appBinaryPath.BeginReading(start);
appBinaryPath.EndReading(end);