pass the buffer size to GetEnvironmentVariable() in characters, not bytes!

svn path=/trunk/; revision=17968
This commit is contained in:
Thomas Bluemel 2005-09-21 17:23:27 +00:00
parent 78e6f0fce1
commit 30da66ac75
3 changed files with 4 additions and 4 deletions

View file

@ -1552,7 +1552,7 @@ Initialize (int argc, TCHAR* argv[])
for you can change the EnvirommentVariable for prompt before cmd start for you can change the EnvirommentVariable for prompt before cmd start
this patch are not 100% right, if it does not exists a PROMPT value cmd should use this patch are not 100% right, if it does not exists a PROMPT value cmd should use
$P$G as defualt not set EnvirommentVariable PROMPT to $P$G if it does not exists */ $P$G as defualt not set EnvirommentVariable PROMPT to $P$G if it does not exists */
if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, 2 * sizeof(TCHAR)) == 0) if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, sizeof(lpBuffer) / sizeof(lpBuffer[0])) == 0)
SetEnvironmentVariable (_T("PROMPT"), _T("$P$G")); SetEnvironmentVariable (_T("PROMPT"), _T("$P$G"));

View file

@ -131,7 +131,7 @@ INT cmd_if (LPTSTR cmd, LPTSTR param)
if (*pp) if (*pp)
{ {
*pp++ = _T('\0'); *pp++ = _T('\0');
ValueSize = GetEnvironmentVariable(param, Value, sizeof Value); ValueSize = GetEnvironmentVariable(param, Value, sizeof(Value) / sizeof(Value[0]));
x_flag ^= (0 == ValueSize) x_flag ^= (0 == ValueSize)
? 0 ? 0
: X_EXEC; : X_EXEC;

View file

@ -157,7 +157,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
if (dwBuffer > ENV_BUFFER_SIZE) if (dwBuffer > ENV_BUFFER_SIZE)
{ {
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR)); pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer * sizeof (TCHAR)); GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer);
} }
@ -222,7 +222,7 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
if (dwBuffer > ENV_BUFFER_SIZE) if (dwBuffer > ENV_BUFFER_SIZE)
{ {
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR)); pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, dwBuffer * sizeof (TCHAR)); GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, dwBuffer);
} }
else if (0 == dwBuffer) else if (0 == dwBuffer)
{ {