1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

out of memory checks: add missing sh_getcwd() wrapper (re: 7ad274f8)

getcwd() with 0/NULL arguments also mallocs, so needs a check.
This commit is contained in:
Martijn Dekker 2021-12-05 22:00:08 +01:00
parent f6a6d236f1
commit a3f4b5efd1
3 changed files with 10 additions and 1 deletions

View file

@ -271,6 +271,14 @@ void *sh_memdup(const void *s, size_t n)
return(dup);
}
char *sh_getcwd(void)
{
char *cwd = getcwd(NIL(char*), 0);
if(!cwd && errno==ENOMEM)
nomemory(0);
return(cwd);
}
#if SHOPT_VSH || SHOPT_ESH
/* Trap for VISUAL and EDITOR variables */
static void put_ed(register Namval_t* np,const char *val,int flags,Namfun_t *fp)