1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-23 14:54:30 +01:00

Fix arg_parse accessing invalid memory due to mistake in setup code. Reintroduced free memory of command line parameters

This commit is contained in:
Duncan Frost
2015-01-18 20:56:08 +00:00
parent e6f966f395
commit efad54f1c6
2 changed files with 5 additions and 7 deletions

View File

@@ -50,10 +50,6 @@ static const char *const usage[] = {
*/
int cmdline_run(const char **argv, int argc)
{
// For argparse's sake, add virtual first argument process path
argc++;
argv--;
//
int version = 0, verbose = 0, width = 0, height = 0;

View File

@@ -70,7 +70,7 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta
// Get command line arguments in standard form
argv = CommandLineToArgvA(lpCmdLine, &argc);
runGame = cmdline_run(argv, argc);
//LocalFree(argv);
GlobalFree(argv);
if (runGame)
openrct2_launch();
@@ -243,11 +243,13 @@ PCHAR *CommandLineToArgvA(PCHAR CmdLine, int *_argc)
i = ((len + 2) / 2)*sizeof(PVOID) + sizeof(PVOID);
argv = (PCHAR*)GlobalAlloc(GMEM_FIXED,
i + (len + 2)*sizeof(CHAR));
i + (len + 2)*sizeof(CHAR) + 1);
_argv = (PCHAR)(((PUCHAR)argv) + i);
argc = 0;
// Add in virtual 1st command line argument, process path, for arg_parse's sake.
argv[0] = 0;
argc = 1;
argv[argc] = _argv;
in_QM = FALSE;
in_TEXT = FALSE;