summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-06-22 07:43:41 (GMT)
committerGitHub <noreply@github.com>2020-06-22 07:43:41 (GMT)
commitd5ee9b9940ba24120838b07061058afe931cfff1 (patch)
tree44e167dcfe54c4e2c39144b09807d2d94cb95331 /Python
parent14195597b3a877209c20d00e0ec844234e624d13 (diff)
downloadcpython-d5ee9b9940ba24120838b07061058afe931cfff1.zip
cpython-d5ee9b9940ba24120838b07061058afe931cfff1.tar.gz
cpython-d5ee9b9940ba24120838b07061058afe931cfff1.tar.bz2
bpo-41056: Fix reference to deallocated stack in pathconfig (Coverity) (GH-21013)
Reported by Coverity. (CID 1457554 RETURN_LOCAL) path0 is assigned as a pointer to this right before it goes out of scope. (cherry picked from commit 81328f30703bd7225e7e73aedb0994a7293ce190) Co-authored-by: Gregory P. Smith <greg@krypto.org>
Diffstat (limited to 'Python')
-rw-r--r--Python/pathconfig.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index 258ff61..bf18097 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -679,6 +679,7 @@ _PyPathConfig_ComputeSysPath0(const PyWideStringList *argv, PyObject **path0_p)
#ifdef HAVE_READLINK
wchar_t link[MAXPATHLEN + 1];
int nr = 0;
+ wchar_t path0copy[2 * MAXPATHLEN + 1];
if (have_script_arg) {
nr = _Py_wreadlink(path0, link, Py_ARRAY_LENGTH(link));
@@ -701,7 +702,6 @@ _PyPathConfig_ComputeSysPath0(const PyWideStringList *argv, PyObject **path0_p)
}
else {
/* Must make a copy, path0copy has room for 2 * MAXPATHLEN */
- wchar_t path0copy[2 * MAXPATHLEN + 1];
wcsncpy(path0copy, path0, MAXPATHLEN);
q = wcsrchr(path0copy, SEP);
wcsncpy(q+1, link, MAXPATHLEN);