diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-22 23:55:19 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-22 23:55:19 +0200 |
commit | 7196af1e77661d5981f36256a627831392e8c220 (patch) | |
tree | 1f190da0a622bef7eb7e8a1e32a5ed742178dbc7 /Python/pythonrun.c | |
parent | 015fad13eabce6c057cbdb62ae93ea80b4803718 (diff) | |
download | cpython-7196af1e77661d5981f36256a627831392e8c220.tar.gz |
Issue #18520: Fix initstdio(), handle PySys_SetObject() failure
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 30e5e6f0c3..18c2baa656 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1159,8 +1159,14 @@ initstdio(void) } PyErr_Clear(); /* Not a fatal error if codec isn't available */ - PySys_SetObject("__stderr__", std); - PySys_SetObject("stderr", std); + if (PySys_SetObject("__stderr__", std) < 0) { + Py_DECREF(std); + goto error; + } + if (PySys_SetObject("stderr", std) < 0) { + Py_DECREF(std); + goto error; + } Py_DECREF(std); #endif |