Commit ed53782e authored by Victor Stinner's avatar Victor Stinner

Issue #25846: Fix usage of Py_ARRAY_LENGTH() in win32_wchdir()

parent 8de795f4
...@@ -1345,13 +1345,13 @@ win32_chdir(LPCSTR path) ...@@ -1345,13 +1345,13 @@ win32_chdir(LPCSTR path)
static BOOL __stdcall static BOOL __stdcall
win32_wchdir(LPCWSTR path) win32_wchdir(LPCWSTR path)
{ {
wchar_t _new_path[MAX_PATH], *new_path = _new_path; wchar_t path_buf[MAX_PATH], *new_path = path_buf;
int result; int result;
wchar_t env[4] = L"=x:"; wchar_t env[4] = L"=x:";
if(!SetCurrentDirectoryW(path)) if(!SetCurrentDirectoryW(path))
return FALSE; return FALSE;
result = GetCurrentDirectoryW(Py_ARRAY_LENGTH(new_path), new_path); result = GetCurrentDirectoryW(Py_ARRAY_LENGTH(path_buf), new_path);
if (!result) if (!result)
return FALSE; return FALSE;
if (result > Py_ARRAY_LENGTH(new_path)) { if (result > Py_ARRAY_LENGTH(new_path)) {
...@@ -1372,7 +1372,7 @@ win32_wchdir(LPCWSTR path) ...@@ -1372,7 +1372,7 @@ win32_wchdir(LPCWSTR path)
return TRUE; return TRUE;
env[1] = new_path[0]; env[1] = new_path[0];
result = SetEnvironmentVariableW(env, new_path); result = SetEnvironmentVariableW(env, new_path);
if (new_path != _new_path) if (new_path != path_buf)
PyMem_RawFree(new_path); PyMem_RawFree(new_path);
return result; return result;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment