summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-07-16 02:32:03 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-07-16 02:32:03 (GMT)
commitfc28e0de584e8040bd27080b0111a722243b82c7 (patch)
tree83830cc5c23708830bda6893b95371e669328e94 /Objects
parent4b0a315c3179c1785fcec6857ed4a69417fd7ae8 (diff)
downloadcpython-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.c6
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);