diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2009-05-02 18:52:14 +0000 |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2009-05-02 18:52:14 +0000 |
commit | db12d454e6176e9c933babe3ce40b225307c6305 (patch) | |
tree | 28b09c64e9dfd797da58a98725bfb93b4dae7077 /Python/marshal.c | |
parent | 02953d244fdb2fe99853d2fe5db905df53c6596f (diff) | |
download | cpython-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.c | 6 |
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; |