Bug 1357154 - Cache Windows executable path after BinaryPath::Get is called in main. r=ehsan

MozReview-Commit-ID: Qby9b4ngz2
This commit is contained in:
Perry Jiang
2017-06-22 10:56:04 -07:00
parent 73146e8b91
commit b18706308f
3 changed files with 53 additions and 10 deletions

View File

@@ -5,6 +5,7 @@
#include "nsWindowsShellService.h"
#include "BinaryPath.h"
#include "city.h"
#include "imgIContainer.h"
#include "imgIRequest.h"
@@ -228,13 +229,10 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
return NS_OK;
}
wchar_t exePath[MAX_BUF] = L"";
if (!::GetModuleFileNameW(0, exePath, MAX_BUF)) {
return NS_OK;
}
// Convert the path to a long path since GetModuleFileNameW returns the path
// that was used to launch Firefox which is not necessarily a long path.
if (!::GetLongPathNameW(exePath, exePath, MAX_BUF)) {
wchar_t exePath[MAXPATHLEN] = L"";
nsresult rv = BinaryPath::GetLong(exePath);
if (NS_FAILED(rv)) {
return NS_OK;
}