summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-09-07 19:38:34 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-09-07 19:38:34 (GMT)
commit3b1bc7828dff9c58031f60f9d603ca78cbba96ea (patch)
tree9e68eff4768bcdb358fc21ac36998cf7bb4fbff2 /Modules/pyexpat.c
parentae0d7527f359e83a86c996ab439c374afca7e8bc (diff)
parent931331a328d522bb014f9e9c13884d7566108268 (diff)
downloadcpython-3b1bc7828dff9c58031f60f9d603ca78cbba96ea.zip
cpython-3b1bc7828dff9c58031f60f9d603ca78cbba96ea.tar.gz
cpython-3b1bc7828dff9c58031f60f9d603ca78cbba96ea.tar.bz2
Issue #25019: Fixed a crash caused by setting non-string key of expat parser.
Added additional tests for expat parser attributes. Based on patch by John Leitch.
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r--Modules/pyexpat.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index a43887e..60f6443 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1378,11 +1378,16 @@ static int
xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
{
/* Set attribute 'name' to value 'v'. v==NULL means delete */
+ if (!PyUnicode_Check(name)) {
+ PyErr_Format(PyExc_TypeError,
+ "attribute name must be string, not '%.200s'",
+ name->ob_type->tp_name);
+ return -1;
+ }
if (v == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Cannot delete attribute");
return -1;
}
- assert(PyUnicode_Check(name));
if (PyUnicode_CompareWithASCIIString(name, "buffer_text") == 0) {
int b = PyObject_IsTrue(v);
if (b < 0)