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

Skip to content

Commit 2f5bbc6

Browse files
committed
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.
1 parent 8bdc130 commit 2f5bbc6

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
@@ -817,8 +817,9 @@ Py_GetPythonHome(void)
817817
if (home == NULL && !Py_IgnoreEnvironmentFlag) {
818818
char* chome = Py_GETENV("PYTHONHOME");
819819
if (chome) {
820-
size_t r = mbstowcs(env_home, chome, PATH_MAX+1);
821-
if (r != (size_t)-1 && r <= PATH_MAX)
820+
size_t size = Py_ARRAY_LENGTH(env_home);
821+
size_t r = mbstowcs(env_home, chome, size);
822+
if (r != (size_t)-1 && r < size)
822823
home = env_home;
823824
}
824825

0 commit comments

Comments
 (0)