comparison Python/pythonrun.c @ 87113:159e51e5fc2c 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.
author Victor Stinner <victor.stinner@gmail.com>
date Fri, 15 Nov 2013 17:09:24 +0100
parents 4c4f31a1b706
children 58ffd70d02b6
comparison
equal deleted inserted replaced
87102:46fc4fb2c8c5 87113:159e51e5fc2c
815 { 815 {
816 wchar_t *home = default_home; 816 wchar_t *home = default_home;
817 if (home == NULL && !Py_IgnoreEnvironmentFlag) { 817 if (home == NULL && !Py_IgnoreEnvironmentFlag) {
818 char* chome = Py_GETENV("PYTHONHOME"); 818 char* chome = Py_GETENV("PYTHONHOME");
819 if (chome) { 819 if (chome) {
820 size_t r = mbstowcs(env_home, chome, PATH_MAX+1); 820 size_t size = Py_ARRAY_LENGTH(env_home);
821 if (r != (size_t)-1 && r <= PATH_MAX) 821 size_t r = mbstowcs(env_home, chome, size);
822 if (r != (size_t)-1 && r < size)
822 home = env_home; 823 home = env_home;
823 } 824 }
824 825
825 } 826 }
826 return home; 827 return home;