[CMD]: Check for cmd_realloc returned value. Adapted from patch by Patrick Martin, see CORE-7298.

svn path=/trunk/; revision=67065
This commit is contained in:
Hermès Bélusca-Maïto 2015-04-05 17:11:29 +00:00
parent a18fba66e3
commit 965df2ffd2
2 changed files with 19 additions and 0 deletions

View file

@ -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);
}

View file

@ -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);
}