mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-32903: Fix a memory leak in os.chdir() on Windows (GH-5801)
This commit is contained in:
parent
982c723384
commit
3e197c7a67
2 changed files with 9 additions and 7 deletions
|
@ -1529,15 +1529,15 @@ win32_wchdir(LPCWSTR path)
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (wcsncmp(new_path, L"\\\\", 2) == 0 ||
|
||||
wcsncmp(new_path, L"//", 2) == 0)
|
||||
/* UNC path, nothing to do. */
|
||||
return TRUE;
|
||||
env[1] = new_path[0];
|
||||
result = SetEnvironmentVariableW(env, new_path);
|
||||
int is_unc_like_path = (wcsncmp(new_path, L"\\\\", 2) == 0 ||
|
||||
wcsncmp(new_path, L"//", 2) == 0);
|
||||
if (!is_unc_like_path) {
|
||||
env[1] = new_path[0];
|
||||
result = SetEnvironmentVariableW(env, new_path);
|
||||
}
|
||||
if (new_path != path_buf)
|
||||
PyMem_RawFree(new_path);
|
||||
return result;
|
||||
return result ? TRUE : FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue