diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-11-15 17:12:14 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-11-15 17:12:14 +0100 |
commit | 911a3af5a75e2f03a3a3067df7e81aa16d0856ad (patch) | |
tree | eecb99adc9e22bb914d928ea0deb484c9254145c /Python/pythonrun.c | |
parent | 869974660f0beefbf5abf76e127308c25eb722ad (diff) | |
parent | c863d54fbba4643a3c4c8d7244222f4131389993 (diff) | |
download | cpython-911a3af5a75e2f03a3a3067df7e81aa16d0856ad.tar.gz |
(Merge 3.3) pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get
the size of the env_home buffer, not PATH_MAX+1. env_home is declared using
MAXPATHLEN+1, and PATH_MAX is not declared on IRIX.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 8ccf70dea9..e427be3174 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -900,8 +900,9 @@ Py_GetPythonHome(void) if (home == NULL && !Py_IgnoreEnvironmentFlag) { char* chome = Py_GETENV("PYTHONHOME"); if (chome) { - size_t r = mbstowcs(env_home, chome, PATH_MAX+1); - if (r != (size_t)-1 && r <= PATH_MAX) + size_t size = Py_ARRAY_LENGTH(env_home); + size_t r = mbstowcs(env_home, chome, size); + if (r != (size_t)-1 && r < size) home = env_home; } |