Check argc before dereferencing argv[1], as we can launch xulrunner with no args if XUL_APP_FILE is set in the environment.
This commit is contained in:
Родитель
6752aa8bea
Коммит
49011d5b0c
|
@ -312,61 +312,63 @@ int main(int argc, char* argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
PRBool registerGlobal = IsArg(argv[1], "register-global");
|
||||
PRBool registerUser = IsArg(argv[1], "register-user");
|
||||
if (registerGlobal || registerUser) {
|
||||
if (argc != 2) {
|
||||
Usage();
|
||||
return 1;
|
||||
}
|
||||
if (argc > 1) {
|
||||
PRBool registerGlobal = IsArg(argv[1], "register-global");
|
||||
PRBool registerUser = IsArg(argv[1], "register-user");
|
||||
if (registerGlobal || registerUser) {
|
||||
if (argc != 2) {
|
||||
Usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> regDir;
|
||||
nsresult rv = GetXULRunnerDir(argv[0], getter_AddRefs(regDir));
|
||||
if (NS_FAILED(rv))
|
||||
nsCOMPtr<nsIFile> regDir;
|
||||
nsresult rv = GetXULRunnerDir(argv[0], getter_AddRefs(regDir));
|
||||
if (NS_FAILED(rv))
|
||||
return 2;
|
||||
|
||||
return RegisterXULRunner(registerGlobal, regDir) ? 0 : 2;
|
||||
}
|
||||
|
||||
registerGlobal = IsArg(argv[1], "unregister-global");
|
||||
registerUser = IsArg(argv[1], "unregister-user");
|
||||
if (IsArg(argv[1], "unregister-global")) {
|
||||
if (argc != 2) {
|
||||
Usage();
|
||||
return 1;
|
||||
return RegisterXULRunner(registerGlobal, regDir) ? 0 : 2;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> regDir;
|
||||
nsresult rv = GetXULRunnerDir(argv[0], getter_AddRefs(regDir));
|
||||
if (NS_FAILED(rv))
|
||||
registerGlobal = IsArg(argv[1], "unregister-global");
|
||||
registerUser = IsArg(argv[1], "unregister-user");
|
||||
if (IsArg(argv[1], "unregister-global")) {
|
||||
if (argc != 2) {
|
||||
Usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> regDir;
|
||||
nsresult rv = GetXULRunnerDir(argv[0], getter_AddRefs(regDir));
|
||||
if (NS_FAILED(rv))
|
||||
return 2;
|
||||
UnregisterXULRunner(registerGlobal, regDir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (IsArg(argv[1], "find-gre")) {
|
||||
if (argc != 3) {
|
||||
Usage();
|
||||
return 1;
|
||||
UnregisterXULRunner(registerGlobal, regDir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char version[MAXPATHLEN];
|
||||
nsresult rv = GRE_GetGREPathForVersion(argv[2], version, MAXPATHLEN);
|
||||
if (NS_FAILED(rv))
|
||||
return 1;
|
||||
if (IsArg(argv[1], "find-gre")) {
|
||||
if (argc != 3) {
|
||||
Usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("%s\n", version);
|
||||
return 0;
|
||||
}
|
||||
char version[MAXPATHLEN];
|
||||
nsresult rv = GRE_GetGREPathForVersion(argv[2], version, MAXPATHLEN);
|
||||
if (NS_FAILED(rv))
|
||||
return 1;
|
||||
|
||||
if (IsArg(argv[1], "gre-version")) {
|
||||
if (argc != 2) {
|
||||
Usage();
|
||||
return 1;
|
||||
printf("%s\n", version);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("%s\n", GRE_BUILD_ID);
|
||||
return 0;
|
||||
if (IsArg(argv[1], "gre-version")) {
|
||||
if (argc != 2) {
|
||||
Usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("%s\n", GRE_BUILD_ID);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
geckoVersion = ParseVersion(GRE_BUILD_ID);
|
||||
|
|
Загрузка…
Ссылка в новой задаче