Skip to content

Commit ef8db59

Browse files
committed
fix: don't force-overwrite argv if do_php_cli is called by embedder
1 parent a1cb5a3 commit ef8db59

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎sapi/cli/php_cli.c‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,12 +1333,16 @@ PHP_CLI_API int do_php_cli(int argc, char *argv[])
13331333
#if defined(PHP_WIN32)
13341334
php_win32_cp_cli_setup();
13351335
orig_cp = (php_win32_cp_get_orig())->id;
1336-
/* Ignore the delivered argv and argc, read from W API. This place
1337-
might be too late though, but this is the earliest place ATW
1338-
we can access the internal charset information from PHP. */
1339-
argv_wide = CommandLineToArgvW(GetCommandLineW(), &num_args);
1340-
PHP_WIN32_CP_W_TO_ANY_ARRAY(argv_wide, num_args, argv, argc)
1341-
using_wide_argv = 1;
1336+
/* Embedders supply their own arguments, we mustn't replace them with
1337+
* the ones by the host process command line. */
1338+
if (argv_save == __argv) {
1339+
/* Ignore the delivered argv and argc, read from W API. This place
1340+
might be too late though, but this is the earliest place ATW
1341+
we can access the internal charset information from PHP. */
1342+
argv_wide = CommandLineToArgvW(GetCommandLineW(), &num_args);
1343+
PHP_WIN32_CP_W_TO_ANY_ARRAY(argv_wide, num_args, argv, argc)
1344+
using_wide_argv = 1;
1345+
}
13421346

13431347
SetConsoleCtrlHandler(php_cli_win32_ctrl_handler, TRUE);
13441348
#endif

0 commit comments

Comments
 (0)