diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-12-08 23:31:48 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-12-08 23:31:48 (GMT) |
commit | e239d23e8cc66605f548585ad4489a8f12fc070d (patch) | |
tree | e165422c11006a4f3595742dd40a7a2095ef59ce /Modules/_lsprof.c | |
parent | 1b2bd3b348d7bb861ae8c92853e5058766ebff80 (diff) | |
download | cpython-e239d23e8cc66605f548585ad4489a8f12fc070d.zip cpython-e239d23e8cc66605f548585ad4489a8f12fc070d.tar.gz cpython-e239d23e8cc66605f548585ad4489a8f12fc070d.tar.bz2 |
Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r-- | Modules/_lsprof.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 048cfc8..cc412bf 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); |