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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user