aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2020-06-22 00:27:20 -0700
committerGitHub <noreply@github.com>2020-06-22 00:27:20 -0700
commit81328f30703bd7225e7e73aedb0994a7293ce190 (patch)
tree3e717474bd4c700ba2c6880add371198fce1ffbd /Python/pathconfig.c
parentSkip tests to fix bot (GH-20777) (diff)
downloadcpython-81328f30703bd7225e7e73aedb0994a7293ce190.tar.gz
cpython-81328f30703bd7225e7e73aedb0994a7293ce190.tar.bz2
cpython-81328f30703bd7225e7e73aedb0994a7293ce190.zip
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.
Diffstat (limited to 'Python/pathconfig.c')
-rw-r--r--Python/pathconfig.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index fe3ac3ee3d8..5c38041d766 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -686,6 +686,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));
@@ -708,7 +709,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);