summaryrefslogtreecommitdiff
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-12-08 23:31:48 +0000
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-12-08 23:31:48 +0000
commite239d23e8cc66605f548585ad4489a8f12fc070d (patch)
treee165422c11006a4f3595742dd40a7a2095ef59ce /Modules/_lsprof.c
parent1b2bd3b348d7bb861ae8c92853e5058766ebff80 (diff)
downloadcpython-git-e239d23e8cc66605f548585ad4489a8f12fc070d.tar.gz
Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r--Modules/_lsprof.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 048cfc8b74..cc412bfc23 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -178,7 +178,16 @@ normalizeUserObj(PyObject *obj)
PyObject *mod = fn->m_module;
const char *modname;
if (mod && PyUnicode_Check(mod)) {
+ /* XXX: The following will truncate module names with embedded
+ * null-characters. It is unlikely that this can happen in
+ * practice and the concequences are not serious enough to
+ * introduce extra checks here.
+ */
modname = _PyUnicode_AsString(mod);
+ if (modname == NULL) {
+ modname = "<encoding error>";
+ PyErr_Clear();
+ }
}
else if (mod && PyModule_Check(mod)) {
modname = PyModule_GetName(mod);