mirror of
https://github.com/python/cpython.git
synced 2025-09-14 20:56:06 +00:00
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.
This commit is contained in:
parent
ea68d83933
commit
fc96437db4
1 changed files with 10 additions and 10 deletions
|
@ -1768,16 +1768,6 @@ pymain_init_tracemalloc(_PyCoreConfig *config)
|
||||||
static _PyInitError
|
static _PyInitError
|
||||||
pymain_init_pycache_prefix(_PyCoreConfig *config)
|
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");
|
const wchar_t *xoption = config_get_xoption(config, L"pycache_prefix");
|
||||||
if (xoption) {
|
if (xoption) {
|
||||||
const wchar_t *sep = wcschr(xoption, L'=');
|
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
|
// -X pycache_prefix= can cancel the env var
|
||||||
config->pycache_prefix = NULL;
|
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();
|
return _Py_INIT_OK();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue