From: Victor Stinner Date: Mon, 22 Jul 2013 21:55:19 +0000 (+0200) Subject: Issue #18520: Fix initstdio(), handle PySys_SetObject() failure X-Git-Tag: v3.4.0a1~97 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ba30883f60271be3b4b8c14735566c943a83c68f;p=thirdparty%2FPython%2Fcpython.git Issue #18520: Fix initstdio(), handle PySys_SetObject() failure --- diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 30e5e6f0c373..18c2baa656d1 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