From: Victor Stinner Date: Fri, 15 Nov 2013 16:09:24 +0000 (+0100) Subject: pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get the size of X-Git-Tag: v3.4.0b1~268^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2f5bbc6a123dfb36ed1f89e9016ec356695bdd8a;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 832df535f869..e02dbe2be181 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -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; }