diff options
author | Alexey Izbyshev <izbyshev@users.noreply.github.com> | 2018-08-19 18:52:04 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-08-19 18:52:04 (GMT) |
commit | 74a307d48ef8b278c4629ca0ef2139be1c9a34e6 (patch) | |
tree | 31591459ce61fa6d19c77151b63912c9db05e208 /Objects | |
parent | 225b05548027d55aafb11b65f6a4a2bef2f5196f (diff) | |
download | cpython-74a307d48ef8b278c4629ca0ef2139be1c9a34e6.zip cpython-74a307d48ef8b278c4629ca0ef2139be1c9a34e6.tar.gz cpython-74a307d48ef8b278c4629ca0ef2139be1c9a34e6.tar.bz2 |
bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823)
Reported by Svace static analyzer.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 0460d18..087cfca 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -6813,8 +6813,6 @@ unicode_encode_ucs1(PyObject *unicode, str = _PyBytesWriter_WriteBytes(&writer, str, PyBytes_AS_STRING(rep), PyBytes_GET_SIZE(rep)); - if (str == NULL) - goto onError; } else { assert(PyUnicode_Check(rep)); @@ -6836,6 +6834,9 @@ unicode_encode_ucs1(PyObject *unicode, PyUnicode_DATA(rep), PyUnicode_GET_LENGTH(rep)); } + if (str == NULL) + goto onError; + pos = newpos; Py_CLEAR(rep); } |