]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get the size of
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 15 Nov 2013 16:09:24 +0000 (17:09 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 15 Nov 2013 16:09:24 +0000 (17:09 +0100)
the env_home buffer, not PATH_MAX+1. env_home is declared using MAXPATHLEN+1,
and PATH_MAX is not declared on IRIX.

Python/pythonrun.c

index 832df535f8694fc9afa86b24278355b65a8b1c05..e02dbe2be181e8f3b870da774f8d909e8e3c782b 100644 (file)
@@ -817,8 +817,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;
         }