summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-03-01 10:28:20 (GMT)
committerXiang Zhang <angwerzx@126.com>2018-03-01 10:28:20 (GMT)
commit10fb1bf7766e7eb9500d328ddd1035e3f823fb57 (patch)
tree89203a1aedb16a199e832ebdd7ddc558575936c6 /Modules
parent32f5392f64f004382e26a988b1145d2dc96c4978 (diff)
downloadcpython-10fb1bf7766e7eb9500d328ddd1035e3f823fb57.zip
cpython-10fb1bf7766e7eb9500d328ddd1035e3f823fb57.tar.gz
cpython-10fb1bf7766e7eb9500d328ddd1035e3f823fb57.tar.bz2
bpo-32903: Fix a memory leak in os.chdir() on Windows (GH-5801) (#5946)
(cherry picked from commit 3e197c7a6740d564ad52fb7901c07d5ff49460f5) Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 885c267..0837a4a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1444,15 +1444,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