summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-06-08 20:46:00 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-06-08 20:46:00 (GMT)
commitecccc4f9b888ddfba057119e33e03b4c1ffdfe0e (patch)
tree949d9d7cf82975a5d7d26db038aa079b375130e4 /Python/sysmodule.c
parent649124856aa994629e574c7a7ecf22d3b07f3ca0 (diff)
downloadcpython-ecccc4f9b888ddfba057119e33e03b4c1ffdfe0e.zip
cpython-ecccc4f9b888ddfba057119e33e03b4c1ffdfe0e.tar.gz
cpython-ecccc4f9b888ddfba057119e33e03b4c1ffdfe0e.tar.bz2
sys_pyfile_write() does nothing if file is NULL
mywrite() falls back to the C file object if sys_pyfile_write() returns an error. This patch fixes a segfault is Py_FatalError() is called in an early stage of Python initialization.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index f1da9730c..9ec8ab1 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1839,6 +1839,9 @@ sys_pyfile_write(const char *text, PyObject *file)
PyObject *unicode = NULL, *writer = NULL, *args = NULL, *result = NULL;
int err;
+ if (file == NULL)
+ return -1;
+
unicode = PyUnicode_FromString(text);
if (unicode == NULL)
goto error;