summaryrefslogtreecommitdiff
path: root/Python/marshal.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2009-05-02 18:52:14 +0000
committerMartin v. Löwis <martin@v.loewis.de>2009-05-02 18:52:14 +0000
commitdb12d454e6176e9c933babe3ce40b225307c6305 (patch)
tree28b09c64e9dfd797da58a98725bfb93b4dae7077 /Python/marshal.c
parent02953d244fdb2fe99853d2fe5db905df53c6596f (diff)
downloadcpython-git-db12d454e6176e9c933babe3ce40b225307c6305.tar.gz
Issue #3672: Reject surrogates in utf-8 codec; add surrogates error
handler.
Diffstat (limited to 'Python/marshal.c')
-rw-r--r--Python/marshal.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index bf7a26b5b2..4ad873eb77 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -312,7 +312,9 @@ w_object(PyObject *v, WFILE *p)
}
else if (PyUnicode_CheckExact(v)) {
PyObject *utf8;
- utf8 = PyUnicode_AsUTF8String(v);
+ utf8 = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(v),
+ PyUnicode_GET_SIZE(v),
+ "surrogates");
if (utf8 == NULL) {
p->depth--;
p->error = WFERR_UNMARSHALLABLE;
@@ -810,7 +812,7 @@ r_object(RFILE *p)
retval = NULL;
break;
}
- v = PyUnicode_DecodeUTF8(buffer, n, NULL);
+ v = PyUnicode_DecodeUTF8(buffer, n, "surrogates");
PyMem_DEL(buffer);
retval = v;
break;