mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
bug 485031 - WinCE Crash on First Startup (or command line environment passing) r=bsmedberg
This commit is contained in:
parent
31e0c98079
commit
c31dd2be09
@ -64,15 +64,18 @@ FreeAllocStrings(int argc, char **argv)
|
||||
|
||||
#ifdef WINCE
|
||||
/** argc/argv are in/out parameters */
|
||||
void ExtractEnvironmentFromCL(int &argc, WCHAR **&argv)
|
||||
void ExtractEnvironmentFromCL(int &argc, char **&argv)
|
||||
{
|
||||
for (int x = 0; x < argc; ++x) {
|
||||
if (!wcsncmp(argv[x], L"--environ:",10)) {
|
||||
char* key_val = AllocConvertUTF16toUTF8(argv[x]+10);
|
||||
for (int x = argc - 1; x >= 0; x--) {
|
||||
if (!strncmp(argv[x], "--environ:", 10)) {
|
||||
char* key_val = strdup(argv[x]+10);
|
||||
putenv(key_val);
|
||||
free(key_val);
|
||||
argc -= 1;
|
||||
memcpy(&argv[x], &argv[x+1], (argc - x) * sizeof(WCHAR*));
|
||||
char *delete_argv = argv[x];
|
||||
if (x < argc) /* if the current argument is not at the tail, shift following arguments. */
|
||||
memcpy(&argv[x], &argv[x+1], (argc - x) * sizeof(char*));
|
||||
delete [] delete_argv;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,9 +84,6 @@ void ExtractEnvironmentFromCL(int &argc, WCHAR **&argv)
|
||||
|
||||
int wmain(int argc, WCHAR **argv)
|
||||
{
|
||||
#ifdef WINCE
|
||||
ExtractEnvironmentFromCL(argc, argv);
|
||||
#endif
|
||||
char **argvConverted = new char*[argc + 1];
|
||||
if (!argvConverted)
|
||||
return 127;
|
||||
@ -94,6 +94,9 @@ int wmain(int argc, WCHAR **argv)
|
||||
return 127;
|
||||
}
|
||||
}
|
||||
#ifdef WINCE
|
||||
ExtractEnvironmentFromCL(argc, argvConverted);
|
||||
#endif
|
||||
argvConverted[argc] = NULL;
|
||||
|
||||
// need to save argvConverted copy for later deletion.
|
||||
@ -102,7 +105,7 @@ int wmain(int argc, WCHAR **argv)
|
||||
FreeAllocStrings(argc, argvConverted);
|
||||
return 127;
|
||||
}
|
||||
for (int i=0; i<argc; i++)
|
||||
for (int i = 0; i < argc; i++)
|
||||
deleteUs[i] = argvConverted[i];
|
||||
int result = main(argc, argvConverted);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user