[Python-checkins] cpython (merge 3.3 -> default): (Merge 3.3) pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get
victor.stinner
python-checkins at python.org
Fri Nov 15 17:13:22 CET 2013
http://hg.python.org/cpython/rev/58ffd70d02b6
changeset: 87114:58ffd70d02b6
parent: 87112:d48ec67b3b0e
parent: 87113:159e51e5fc2c
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Nov 15 17:12:14 2013 +0100
summary:
(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.
files:
Python/pythonrun.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -900,8 +900,9 @@
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;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list