diff --git a/reactos/base/shell/cmd/path.c b/reactos/base/shell/cmd/path.c index ab29938cd0d..3e586928608 100644 --- a/reactos/base/shell/cmd/path.c +++ b/reactos/base/shell/cmd/path.c @@ -59,7 +59,13 @@ INT cmd_path (LPTSTR param) } else if (dwBuffer > ENV_BUFFER_SIZE) { + LPTSTR pszOldBuffer = pszBuffer; pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR)); + if (pszBuffer == NULL) + { + cmd_free(pszOldBuffer); + return 1; + } GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer); } diff --git a/reactos/base/shell/cmd/where.c b/reactos/base/shell/cmd/where.c index dfe4d6d2ffb..00aaf7b008b 100644 --- a/reactos/base/shell/cmd/where.c +++ b/reactos/base/shell/cmd/where.c @@ -152,7 +152,13 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) dwBuffer = GetEnvironmentVariable (_T("PATHEXT"), pszPathExt, ENV_BUFFER_SIZE); if (dwBuffer > ENV_BUFFER_SIZE) { + LPTSTR pszOldPathExt = pszPathExt; pszPathExt = (LPTSTR)cmd_realloc (pszPathExt, dwBuffer * sizeof (TCHAR)); + if (pszPathExt == NULL) + { + cmd_free(pszOldPathExt); + return FALSE; + } GetEnvironmentVariable (_T("PATHEXT"), pszPathExt, dwBuffer); _tcslwr(pszPathExt); } @@ -184,7 +190,14 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) dwBuffer = GetEnvironmentVariable (_T("PATH"), pszPath, ENV_BUFFER_SIZE); if (dwBuffer > ENV_BUFFER_SIZE) { + LPTSTR pszOldPath = pszPath; pszPath = (LPTSTR)cmd_realloc (pszPath, dwBuffer * sizeof (TCHAR)); + if (pszPath == NULL) + { + cmd_free(pszOldPath); + cmd_free(pszPathExt); + return FALSE; + } GetEnvironmentVariable (_T("PATH"), pszPath, dwBuffer); }