mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:03:57 +08:00
check allocated memory when setting SHLVL
This commit is contained in:
parent
f47caefdb9
commit
b9b6e867df
4
env.c
4
env.c
|
@ -655,8 +655,12 @@ void env_init()
|
|||
wchar_t *nshlvl, **end_nshlvl;
|
||||
/* add an extra space for digit dump (9+1=10) */
|
||||
size_t i = wcslen( shlvl ) + 2 * sizeof(wchar_t);
|
||||
|
||||
nshlvl = malloc(i);
|
||||
end_nshlvl = calloc( 1, sizeof(nshlvl) );
|
||||
if ( !nshlvl || !end_nshlvl )
|
||||
DIE_MEM();
|
||||
|
||||
if ( nshlvl && swprintf( nshlvl, i,
|
||||
L"%ld", wcstoul( shlvl, end_nshlvl, 10 )+1 ) != -1 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user