Kaydet (Commit) 3e197c7a authored tarafından Alexey Izbyshev's avatar Alexey Izbyshev Kaydeden (comit) Xiang Zhang

bpo-32903: Fix a memory leak in os.chdir() on Windows (GH-5801)

üst 982c7233
Fix a memory leak in os.chdir() on Windows if the current directory is set
to a UNC path.
...@@ -1529,15 +1529,15 @@ win32_wchdir(LPCWSTR path) ...@@ -1529,15 +1529,15 @@ win32_wchdir(LPCWSTR path)
return FALSE; return FALSE;
} }
} }
if (wcsncmp(new_path, L"\\\\", 2) == 0 || int is_unc_like_path = (wcsncmp(new_path, L"\\\\", 2) == 0 ||
wcsncmp(new_path, L"//", 2) == 0) wcsncmp(new_path, L"//", 2) == 0);
/* UNC path, nothing to do. */ if (!is_unc_like_path) {
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 != path_buf) if (new_path != path_buf)
PyMem_RawFree(new_path); PyMem_RawFree(new_path);
return result; return result ? TRUE : FALSE;
} }
#endif #endif
......
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