[PATCH 0/1] MR867: ntdll: Check for failure from get_initial_environment().
Alternatively, since this is early in startup and we don't expect this malloc() to fail, we could simply remove the check from get_initial_environment() itself. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/867
From: Zebediah Figura <zfigura(a)codeweavers.com> This avoids a gcc warning: In function ‘build_initial_params’, inlined from ‘init_startup_info’ at ../wine/dlls/ntdll/unix/env.c:2004:18: ../wine/dlls/ntdll/unix/env.c:1910:12: error: ‘env_pos’ may be used uninitialized [-Werror=maybe-uninitialized] 1910 | path = get_env_var( env, env_pos, pathW, 4 ); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../wine/dlls/ntdll/unix/env.c: In function ‘init_startup_info’: ../wine/dlls/ntdll/unix/env.c:1903:18: note: ‘env_pos’ declared here 1903 | SIZE_T size, env_pos, env_size; | ^~~~~~~ --- dlls/ntdll/unix/env.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 105038a34cb..b7ed4a22b1c 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1901,11 +1901,12 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module ) static const WCHAR pathW[] = {'P','A','T','H'}; RTL_USER_PROCESS_PARAMETERS *params = NULL; SIZE_T size, env_pos, env_size; - WCHAR *dst, *image, *cmdline, *path, *bootstrap; - WCHAR *env = get_initial_environment( &env_pos, &env_size ); + WCHAR *dst, *image, *cmdline, *path, *bootstrap, *env; WCHAR *curdir = get_initial_directory(); NTSTATUS status; + if (!(env = get_initial_environment( &env_pos, &env_size ))) return NULL; + /* store the initial PATH value */ path = get_env_var( env, env_pos, pathW, 4 ); add_dynamic_environment( &env, &env_pos, &env_size ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/867
Alternatively, since this is early in startup and we don't expect this malloc() to fail, we could simply remove the check from get_initial_environment() itself.
That would be better, the error checks are a waste of time here. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/867#note_8675
participants (3)
-
Alexandre Julliard (@julliard) -
Zebediah Figura -
Zebediah Figura (@zfigura)