We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8bdc130 commit 2f5bbc6Copy full SHA for 2f5bbc6
1 file changed
Python/pythonrun.c
@@ -817,8 +817,9 @@ Py_GetPythonHome(void)
817
if (home == NULL && !Py_IgnoreEnvironmentFlag) {
818
char* chome = Py_GETENV("PYTHONHOME");
819
if (chome) {
820
- size_t r = mbstowcs(env_home, chome, PATH_MAX+1);
821
- if (r != (size_t)-1 && r <= PATH_MAX)
+ size_t size = Py_ARRAY_LENGTH(env_home);
+ size_t r = mbstowcs(env_home, chome, size);
822
+ if (r != (size_t)-1 && r < size)
823
home = env_home;
824
}
825
0 commit comments