Skip to content

Commit

Permalink
(Merge 3.3) pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH(…
Browse files Browse the repository at this point in the history
…) 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.
  • Loading branch information
vstinner committed Nov 15, 2013
2 parents 39ecf2e + 2f5bbc6 commit b5a7a0a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b5a7a0a

Please sign in to comment.