Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 87114:58ffd70d02b6
(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.
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Fri, 15 Nov 2013 17:12:14 +0100 |
| parents | 518e3b174120 159e51e5fc2c |
| children | adb471b9cba1 |
line wrap: on
line diff
--- a/Python/pythonrun.c Fri Nov 15 07:41:10 2013 -0800 +++ b/Python/pythonrun.c Fri Nov 15 17:12:14 2013 +0100 @@ -900,8 +900,9 @@ 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; }
