diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-09-08 07:43:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-08 07:43:54 (GMT) |
commit | ddb536ba7b7c6022424e39d666c3cc81772645c0 (patch) | |
tree | 48ba8d3f97ac4b4b060c910db81cf48bb16ba896 /Objects/unicodeobject.c | |
parent | 9f2b3d4c2899f9caea2e47063061a76e460ac618 (diff) | |
download | cpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.zip cpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.tar.gz cpython-ddb536ba7b7c6022424e39d666c3cc81772645c0.tar.bz2 |
[3.6] bpo-31393: Fix the use of PyUnicode_READY(). (GH-3451). (#3453)
(cherry picked from commit e3b2b4b8d9e751b49e3550cb83ba39b54fdc377c)
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1650370..1f221af 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4210,10 +4210,13 @@ PyUnicode_ReadChar(PyObject *unicode, Py_ssize_t index) void *data; int kind; - if (!PyUnicode_Check(unicode) || PyUnicode_READY(unicode) == -1) { + if (!PyUnicode_Check(unicode)) { PyErr_BadArgument(); return (Py_UCS4)-1; } + if (PyUnicode_READY(unicode) == -1) { + return (Py_UCS4)-1; + } if (index < 0 || index >= PyUnicode_GET_LENGTH(unicode)) { PyErr_SetString(PyExc_IndexError, "string index out of range"); return (Py_UCS4)-1; @@ -11706,10 +11709,13 @@ unicode_getitem(PyObject *self, Py_ssize_t index) enum PyUnicode_Kind kind; Py_UCS4 ch; - if (!PyUnicode_Check(self) || PyUnicode_READY(self) == -1) { + if (!PyUnicode_Check(self)) { PyErr_BadArgument(); return NULL; } + if (PyUnicode_READY(self) == -1) { + return NULL; + } if (index < 0 || index >= PyUnicode_GET_LENGTH(self)) { PyErr_SetString(PyExc_IndexError, "string index out of range"); return NULL; |