mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
(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.
This commit is contained in:
commit
b5a7a0aa3f
1 changed files with 3 additions and 2 deletions
|
@ -900,8 +900,9 @@ Py_GetPythonHome(void)
|
||||||
if (home == NULL && !Py_IgnoreEnvironmentFlag) {
|
if (home == NULL && !Py_IgnoreEnvironmentFlag) {
|
||||||
char* chome = Py_GETENV("PYTHONHOME");
|
char* chome = Py_GETENV("PYTHONHOME");
|
||||||
if (chome) {
|
if (chome) {
|
||||||
size_t r = mbstowcs(env_home, chome, PATH_MAX+1);
|
size_t size = Py_ARRAY_LENGTH(env_home);
|
||||||
if (r != (size_t)-1 && r <= PATH_MAX)
|
size_t r = mbstowcs(env_home, chome, size);
|
||||||
|
if (r != (size_t)-1 && r < size)
|
||||||
home = env_home;
|
home = env_home;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue