mirror of
https://github.com/python/cpython.git
synced 2026-04-22 03:41:08 +00:00
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:
parent
0e1e8dbb0b
commit
1e596d3a20
1 changed files with 3 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue