Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b5a7a0a

Browse files
committed
(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.
2 parents 39ecf2e + 2f5bbc6 commit b5a7a0a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Python/pythonrun.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,9 @@ Py_GetPythonHome(void)
900900
if (home == NULL && !Py_IgnoreEnvironmentFlag) {
901901
char* chome = Py_GETENV("PYTHONHOME");
902902
if (chome) {
903-
size_t r = mbstowcs(env_home, chome, PATH_MAX+1);
904-
if (r != (size_t)-1 && r <= PATH_MAX)
903+
size_t size = Py_ARRAY_LENGTH(env_home);
904+
size_t r = mbstowcs(env_home, chome, size);
905+
if (r != (size_t)-1 && r < size)
905906
home = env_home;
906907
}
907908

0 commit comments

Comments
 (0)