comparison Python/pythonrun.c @ 87114:58ffd70d02b6

(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.
author Victor Stinner <victor.stinner@gmail.com>
date Fri, 15 Nov 2013 17:12:14 +0100
parents 518e3b174120 159e51e5fc2c
children adb471b9cba1
comparison
equal deleted inserted replaced
87112:d48ec67b3b0e 87114:58ffd70d02b6
898 { 898 {
899 wchar_t *home = default_home; 899 wchar_t *home = default_home;
900 if (home == NULL && !Py_IgnoreEnvironmentFlag) { 900 if (home == NULL && !Py_IgnoreEnvironmentFlag) {
901 char* chome = Py_GETENV("PYTHONHOME"); 901 char* chome = Py_GETENV("PYTHONHOME");
902 if (chome) { 902 if (chome) {
903 size_t r = mbstowcs(env_home, chome, PATH_MAX+1); 903 size_t size = Py_ARRAY_LENGTH(env_home);
904 if (r != (size_t)-1 && r <= PATH_MAX) 904 size_t r = mbstowcs(env_home, chome, size);
905 if (r != (size_t)-1 && r < size)
905 home = env_home; 906 home = env_home;
906 } 907 }
907 908
908 } 909 }
909 return home; 910 return home;