[PATCH v2 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. -- v2: ntdll: Do not check for malloc() failure in get_initial_environment. https://gitlab.winehq.org/wine/wine/-/merge_requests/867
From: Zebediah Figura <zfigura(a)codeweavers.com> This is called early in process startup; malloc() should definitely never fail here. This fixes an uninitialized variable warning with gcc 12.2: 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 105038a34cb..6e5004a6e11 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -920,7 +920,7 @@ static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) *size = 1; for (e = main_envp; *e; e++) *size += strlen(*e) + 1; - if (!(env = malloc( *size * sizeof(WCHAR) ))) return NULL; + env = malloc( *size * sizeof(WCHAR) ); ptr = env; end = env + *size - 1; for (e = main_envp; *e && ptr < end; e++) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/867
participants (2)
-
Zebediah Figura -
Zebediah Figura (@zfigura)