diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-07-16 02:32:03 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-07-16 02:32:03 (GMT) |
commit | fc28e0de584e8040bd27080b0111a722243b82c7 (patch) | |
tree | 83830cc5c23708830bda6893b95371e669328e94 /Objects | |
parent | 4b0a315c3179c1785fcec6857ed4a69417fd7ae8 (diff) | |
download | cpython-fc28e0de584e8040bd27080b0111a722243b82c7.zip cpython-fc28e0de584e8040bd27080b0111a722243b82c7.tar.gz cpython-fc28e0de584e8040bd27080b0111a722243b82c7.tar.bz2 |
Handle a NULL name properly.
Reported by Klocwork #67
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/fileobject.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 76b7da6..5297538 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -411,11 +411,11 @@ file_repr(PyFileObject *f) if (PyUnicode_Check(f->f_name)) { #ifdef Py_USING_UNICODE PyObject *ret = NULL; - PyObject *name; - name = PyUnicode_AsUnicodeEscapeString(f->f_name); + PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name); + const char *name_str = name ? PyString_AsString(name) : "?"; ret = PyString_FromFormat("<%s file u'%s', mode '%s' at %p>", f->f_fp == NULL ? "closed" : "open", - PyString_AsString(name), + name_str, PyString_AsString(f->f_mode), f); Py_XDECREF(name); |