diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-08-23 11:04:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-23 11:04:16 +0100 |
commit | c48682509dc49b43fe914fe6c502bc390345d1c2 (patch) | |
tree | 2558ec6d9de1ec6575d03bdd41843b108d59278a /Python/sysmodule.c | |
parent | d288b29fc652d27191bde3b3c9145c2eb8169929 (diff) | |
download | cpython-git-c48682509dc49b43fe914fe6c502bc390345d1c2.tar.gz |
bpo-37926: Fix PySys_SetArgvEx(0, NULL, 0) crash (GH-15415)
empty_argv is no longer static in Python 3.8, but it is declared in
a temporary scope, whereas argv keeps a reference to it.
empty_argv memory (allocated on the stack) is reused by
make_sys_argv() code which is inlined when using gcc -O3.
Define empty_argv in PySys_SetArgvEx() body, to ensure
that it remains valid for the whole lifetime of
the PySys_SetArgvEx() call.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index a89ebceb66..738bbc826f 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -3058,11 +3058,11 @@ make_sys_argv(int argc, wchar_t * const * argv) void PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) { + wchar_t* empty_argv[1] = {L""}; PyThreadState *tstate = _PyThreadState_GET(); if (argc < 1 || argv == NULL) { /* Ensure at least one (empty) argument is seen */ - wchar_t* empty_argv[1] = {L""}; argv = empty_argv; argc = 1; } |