summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-15 16:12:14 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-15 16:12:14 (GMT)
commitb5a7a0aa3f9360a84fd5e96e415af277156d4988 (patch)
tree337689527a9697697d3dc60b2af712ba0f1786fb /Python/pythonrun.c
parent39ecf2ed13f9500f6e69b1b5298f8f7b0f83d074 (diff)
parent2f5bbc6a123dfb36ed1f89e9016ec356695bdd8a (diff)
downloadcpython-b5a7a0aa3f9360a84fd5e96e415af277156d4988.zip
cpython-b5a7a0aa3f9360a84fd5e96e415af277156d4988.tar.gz
cpython-b5a7a0aa3f9360a84fd5e96e415af277156d4988.tar.bz2
(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.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 8ccf70d..e427be3 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -900,8 +900,9 @@ Py_GetPythonHome(void)
if (home == NULL && !Py_IgnoreEnvironmentFlag) {
char* chome = Py_GETENV("PYTHONHOME");
if (chome) {
- size_t r = mbstowcs(env_home, chome, PATH_MAX+1);
- if (r != (size_t)-1 && r <= PATH_MAX)
+ size_t size = Py_ARRAY_LENGTH(env_home);
+ size_t r = mbstowcs(env_home, chome, size);
+ if (r != (size_t)-1 && r < size)
home = env_home;
}