mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
[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:
parent
a18fba66e3
commit
965df2ffd2
2 changed files with 19 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue