summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-12-03 09:15:02 (GMT)
committerGitHub <noreply@github.com>2018-12-03 09:15:02 (GMT)
commit0f9b6687eb8b26dd804abcc6efd4d6430ae16f24 (patch)
treeae10652ac48ab1e41fb0b1c9a0f6cbde41b496ea /Objects
parentf65ede3f8fa08493facf48177540d0ec26e59560 (diff)
downloadcpython-0f9b6687eb8b26dd804abcc6efd4d6430ae16f24.zip
cpython-0f9b6687eb8b26dd804abcc6efd4d6430ae16f24.tar.gz
cpython-0f9b6687eb8b26dd804abcc6efd4d6430ae16f24.tar.bz2
bpo-35372: Fix the code page decoder for input > 2 GiB. (GH-10848)
(cherry picked from commit 4013c179117754b039957db4730880bf3285919d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 29b0198..0e64bf9 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -7285,7 +7285,7 @@ decode_code_page_errors(UINT code_page,
"in the target code page.";
/* each step cannot decode more than 1 character, but a character can be
represented as a surrogate pair */
- wchar_t buffer[2], *startout, *out;
+ wchar_t buffer[2], *out;
int insize;
Py_ssize_t outsize;
PyObject *errorHandler = NULL;
@@ -7322,7 +7322,7 @@ decode_code_page_errors(UINT code_page,
*v = (PyObject*)_PyUnicode_New(size * Py_ARRAY_LENGTH(buffer));
if (*v == NULL)
goto error;
- startout = PyUnicode_AS_UNICODE(*v);
+ out = PyUnicode_AS_UNICODE(*v);
}
else {
/* Extend unicode object */
@@ -7333,11 +7333,10 @@ decode_code_page_errors(UINT code_page,
}
if (unicode_resize(v, n + size * Py_ARRAY_LENGTH(buffer)) < 0)
goto error;
- startout = PyUnicode_AS_UNICODE(*v) + n;
+ out = PyUnicode_AS_UNICODE(*v) + n;
}
/* Decode the byte string character per character */
- out = startout;
while (in < endin)
{
/* Decode a character */
@@ -7392,7 +7391,7 @@ decode_code_page_errors(UINT code_page,
*out = 0;
/* Extend unicode object */
- outsize = out - startout;
+ outsize = out - PyUnicode_AS_UNICODE(*v);
assert(outsize <= PyUnicode_WSTR_LENGTH(*v));
if (unicode_resize(v, outsize) < 0)
goto error;