mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
ntdll: Use environ/_NSGetEnviron() directly rather than caching it in main_envp.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57005
This commit is contained in:
parent
0291c9f9fb
commit
8cb1009e4c
Notes:
Alexandre Julliard
2024-07-31 23:44:16 +02:00
Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/wine/-/merge_requests/6178
4 changed files with 9 additions and 11 deletions
|
@ -44,6 +44,10 @@
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# include <CoreFoundation/CFLocale.h>
|
# include <CoreFoundation/CFLocale.h>
|
||||||
# include <CoreFoundation/CFString.h>
|
# include <CoreFoundation/CFString.h>
|
||||||
|
# include <crt_externs.h>
|
||||||
|
# define environ (*_NSGetEnviron())
|
||||||
|
#else
|
||||||
|
extern char **environ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ntstatus.h"
|
#include "ntstatus.h"
|
||||||
|
@ -70,7 +74,6 @@ static const WCHAR bootstrapW[] = {'W','I','N','E','B','O','O','T','S','T','R','
|
||||||
|
|
||||||
int main_argc = 0;
|
int main_argc = 0;
|
||||||
char **main_argv = NULL;
|
char **main_argv = NULL;
|
||||||
char **main_envp = NULL;
|
|
||||||
WCHAR **main_wargv = NULL;
|
WCHAR **main_wargv = NULL;
|
||||||
|
|
||||||
static LCID user_lcid, system_lcid;
|
static LCID user_lcid, system_lcid;
|
||||||
|
@ -931,12 +934,12 @@ static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size )
|
||||||
|
|
||||||
/* estimate needed size */
|
/* estimate needed size */
|
||||||
*size = 1;
|
*size = 1;
|
||||||
for (e = main_envp; *e; e++) *size += strlen(*e) + 1;
|
for (e = environ; *e; e++) *size += strlen(*e) + 1;
|
||||||
|
|
||||||
env = malloc( *size * sizeof(WCHAR) );
|
env = malloc( *size * sizeof(WCHAR) );
|
||||||
ptr = env;
|
ptr = env;
|
||||||
end = env + *size - 1;
|
end = env + *size - 1;
|
||||||
for (e = main_envp; *e && ptr < end; e++)
|
for (e = environ; *e && ptr < end; e++)
|
||||||
{
|
{
|
||||||
char *str = *e;
|
char *str = *e;
|
||||||
|
|
||||||
|
|
|
@ -1953,7 +1953,6 @@ static jstring wine_init_jni( JNIEnv *env, jobject obj, jobjectArray cmdline, jo
|
||||||
|
|
||||||
main_argc = argc;
|
main_argc = argc;
|
||||||
main_argv = argv;
|
main_argv = argv;
|
||||||
main_envp = environ;
|
|
||||||
|
|
||||||
init_paths( argv );
|
init_paths( argv );
|
||||||
virtual_init();
|
virtual_init();
|
||||||
|
@ -2149,11 +2148,10 @@ static void check_command_line( int argc, char *argv[] )
|
||||||
*
|
*
|
||||||
* Main entry point called by the wine loader.
|
* Main entry point called by the wine loader.
|
||||||
*/
|
*/
|
||||||
DECLSPEC_EXPORT void __wine_main( int argc, char *argv[], char *envp[] )
|
DECLSPEC_EXPORT void __wine_main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
main_argc = argc;
|
main_argc = argc;
|
||||||
main_argv = argv;
|
main_argv = argv;
|
||||||
main_envp = envp;
|
|
||||||
|
|
||||||
init_paths( argv );
|
init_paths( argv );
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,6 @@ extern SIZE_T startup_info_size;
|
||||||
extern BOOL is_prefix_bootstrap;
|
extern BOOL is_prefix_bootstrap;
|
||||||
extern int main_argc;
|
extern int main_argc;
|
||||||
extern char **main_argv;
|
extern char **main_argv;
|
||||||
extern char **main_envp;
|
|
||||||
extern WCHAR **main_wargv;
|
extern WCHAR **main_wargv;
|
||||||
extern const WCHAR system_dir[];
|
extern const WCHAR system_dir[];
|
||||||
extern unsigned int supported_machines_count;
|
extern unsigned int supported_machines_count;
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
extern char **environ;
|
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__x86_64__) && !defined(HAVE_WINE_PRELOADER)
|
#if defined(__APPLE__) && defined(__x86_64__) && !defined(HAVE_WINE_PRELOADER)
|
||||||
|
|
||||||
/* Not using the preloader on x86_64:
|
/* Not using the preloader on x86_64:
|
||||||
|
@ -260,8 +258,8 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
if ((handle = load_ntdll( argv[0] )))
|
if ((handle = load_ntdll( argv[0] )))
|
||||||
{
|
{
|
||||||
void (*init_func)(int, char **, char **) = dlsym( handle, "__wine_main" );
|
void (*init_func)(int, char **) = dlsym( handle, "__wine_main" );
|
||||||
if (init_func) init_func( argc, argv, environ );
|
if (init_func) init_func( argc, argv );
|
||||||
fprintf( stderr, "wine: __wine_main function not found in ntdll.so\n" );
|
fprintf( stderr, "wine: __wine_main function not found in ntdll.so\n" );
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue