summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-07-26 06:01:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-07-26 06:01:22 (GMT)
commit83236f7a8b638454ea74743e1103faa0545e9a62 (patch)
treec5aa126ac3d23fd73dcd592c5c60076eb0a90fb2 /Modules
parent5a294d822b7f5732135662907ec1a1d4a7b0fc9a (diff)
downloadcpython-83236f7a8b638454ea74743e1103faa0545e9a62.zip
cpython-83236f7a8b638454ea74743e1103faa0545e9a62.tar.gz
cpython-83236f7a8b638454ea74743e1103faa0545e9a62.tar.bz2
Issue #24683: Fixed crashes in _json functions called with arguments of
inappropriate type.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_json.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 2f42c34..dded2c9 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1223,11 +1223,19 @@ encoder_init(PyObject *self, PyObject *args, PyObject *kwds)
assert(PyEncoder_Check(self));
s = (PyEncoderObject *)self;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOOOp:make_encoder", kwlist,
- &markers, &defaultfn, &encoder, &indent, &key_separator, &item_separator,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOUUOOp:make_encoder", kwlist,
+ &markers, &defaultfn, &encoder, &indent,
+ &key_separator, &item_separator,
&sort_keys, &skipkeys, &allow_nan))
return -1;
+ if (markers != Py_None && !PyDict_Check(markers)) {
+ PyErr_Format(PyExc_TypeError,
+ "make_encoder() argument 1 must be dict or None, "
+ "not %.200s", Py_TYPE(markers)->tp_name);
+ return -1;
+ }
+
s->markers = markers;
s->defaultfn = defaultfn;
s->encoder = encoder;