diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-06-08 20:46:00 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-06-08 20:46:00 +0000 |
commit | ea1eb94ef3c07f1a17798ab62b20d374266920a7 (patch) | |
tree | 9fd1a07ceee64be8636b5f8005bea6d27feb3ea6 /Python | |
parent | 9120b64e0d8d3d0a8183e08e014998ba4770841c (diff) | |
download | cpython-ea1eb94ef3c07f1a17798ab62b20d374266920a7.tar.gz |
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')
-rw-r--r-- | Python/sysmodule.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index f1da9730c4..9ec8ab1489 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; |