summaryrefslogtreecommitdiffstats
path: root/Modules/getpath.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-16 23:38:07 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-16 23:38:07 (GMT)
commit61aad57dc9df19c2e073779e0ab389b949960801 (patch)
treef9cb4ae17ba52a961c1beb93829dda1b02f7a04d /Modules/getpath.c
parentdc4b2a712f96aa6a27d65af27ca877b084a584ca (diff)
downloadcpython-61aad57dc9df19c2e073779e0ab389b949960801.zip
cpython-61aad57dc9df19c2e073779e0ab389b949960801.tar.gz
cpython-61aad57dc9df19c2e073779e0ab389b949960801.tar.bz2
Oops, fix my previous commit (r85583) on calculate_path()
path value may be changed, so keep a copy in a new variable.
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r--Modules/getpath.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 776c464..20030ce 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -407,6 +407,7 @@ calculate_path(void)
wchar_t rtpypath[MAXPATHLEN+1];
wchar_t *home = Py_GetPythonHome();
char *_path = getenv("PATH");
+ wchar_t *path_buffer = NULL;
wchar_t *path = NULL;
wchar_t *prog = Py_GetProgramName();
wchar_t argv0_path[MAXPATHLEN+1];
@@ -428,8 +429,10 @@ calculate_path(void)
char execpath[MAXPATHLEN+1];
#endif
- if (_path)
- path = _Py_char2wchar(_path, NULL);
+ if (_path) {
+ path_buffer = _Py_char2wchar(_path, NULL);
+ path = path_buffer;
+ }
/* If there is no slash in the argv0 path, then we have to
* assume python is on the user's $PATH, since there's no
@@ -484,8 +487,8 @@ calculate_path(void)
}
else
progpath[0] = '\0';
- if (path != NULL)
- PyMem_Free(path);
+ if (path_buffer != NULL)
+ PyMem_Free(path_buffer);
if (progpath[0] != SEP && progpath[0] != '\0')
absolutize(progpath);
wcsncpy(argv0_path, progpath, MAXPATHLEN);