diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-08-01 14:16:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 14:16:46 (GMT) |
commit | fc96437db4fa95dff99d43d4500beaf12bad5bff (patch) | |
tree | 8d11ca7612fee6de796d1e11c21959fc111cc4f7 /Modules/main.c | |
parent | ea68d83933e6de6cabfb115ec1b8888301947369 (diff) | |
download | cpython-fc96437db4fa95dff99d43d4500beaf12bad5bff.zip cpython-fc96437db4fa95dff99d43d4500beaf12bad5bff.tar.gz cpython-fc96437db4fa95dff99d43d4500beaf12bad5bff.tar.bz2 |
bpo-33499: Fix pymain_init_pycache_prefix() (GH-8596)
Fix a memory leak in pymain_init_pycache_prefix()
when PYTHONPYCACHEPREFIX and -X pycache_prefix are used.
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Modules/main.c b/Modules/main.c index 664a70a..34069e1 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -1768,16 +1768,6 @@ pymain_init_tracemalloc(_PyCoreConfig *config) static _PyInitError pymain_init_pycache_prefix(_PyCoreConfig *config) { - wchar_t *env; - - int res = config_get_env_var_dup(config, &env, - L"PYTHONPYCACHEPREFIX", "PYTHONPYCACHEPREFIX"); - if (res < 0) { - return DECODE_LOCALE_ERR("PYTHONPYCACHEPREFIX", res); - } else if (env) { - config->pycache_prefix = env; - } - const wchar_t *xoption = config_get_xoption(config, L"pycache_prefix"); if (xoption) { const wchar_t *sep = wcschr(xoption, L'='); @@ -1790,6 +1780,16 @@ pymain_init_pycache_prefix(_PyCoreConfig *config) // -X pycache_prefix= can cancel the env var config->pycache_prefix = NULL; } + return _Py_INIT_OK(); + } + + wchar_t *env; + int res = config_get_env_var_dup(config, &env, + L"PYTHONPYCACHEPREFIX", "PYTHONPYCACHEPREFIX"); + if (res < 0) { + return DECODE_LOCALE_ERR("PYTHONPYCACHEPREFIX", res); + } else if (env) { + config->pycache_prefix = env; } return _Py_INIT_OK(); |