bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823)

Reported by Svace static analyzer.
(cherry picked from commit 74a307d48e)

Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2018-08-19 16:17:53 -04:00 committed by GitHub
parent 0e1e8dbb0b
commit 1e596d3a20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6812,8 +6812,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));
@ -6835,6 +6833,9 @@ unicode_encode_ucs1(PyObject *unicode,
PyUnicode_DATA(rep),
PyUnicode_GET_LENGTH(rep));
}
if (str == NULL)
goto onError;
pos = newpos;
Py_CLEAR(rep);
}