summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-06-29 22:36:49 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2009-06-29 22:36:49 (GMT)
commit84ec8d931404f4f9037242ec933fdcdcd4870114 (patch)
tree4936dae944a05bf26858b44065def904c8d23fac /Objects
parentf909202c11e0a304486c9fb71458e19a598d10c0 (diff)
downloadcpython-84ec8d931404f4f9037242ec933fdcdcd4870114.zip
cpython-84ec8d931404f4f9037242ec933fdcdcd4870114.tar.gz
cpython-84ec8d931404f4f9037242ec933fdcdcd4870114.tar.bz2
#6373: SystemError in str.encode('latin1', 'surrogateescape')
if the string contains unpaired surrogates. (In debug build, crash in assert()) This can happen with normal processing, if python starts with utf-8, then calls sys.setfilesystemencoding('latin-1')
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 0d4a3dd..305289b 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -4201,10 +4201,12 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p,
repsize = PyBytes_Size(repunicode);
if (repsize > 1) {
/* Make room for all additional bytes. */
+ respos = str - PyBytes_AS_STRING(res);
if (_PyBytes_Resize(&res, ressize+repsize-1)) {
Py_DECREF(repunicode);
goto onError;
}
+ str = PyBytes_AS_STRING(res) + respos;
ressize += repsize-1;
}
memcpy(str, PyBytes_AsString(repunicode), repsize);