Skip to content

Commit 1e596d3

Browse files
bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823)
Reported by Svace static analyzer. (cherry picked from commit 74a307d) Co-authored-by: Alexey Izbyshev <[email protected]>
1 parent 0e1e8db commit 1e596d3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Objects/unicodeobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6812,8 +6812,6 @@ unicode_encode_ucs1(PyObject *unicode,
68126812
str = _PyBytesWriter_WriteBytes(&writer, str,
68136813
PyBytes_AS_STRING(rep),
68146814
PyBytes_GET_SIZE(rep));
6815-
if (str == NULL)
6816-
goto onError;
68176815
}
68186816
else {
68196817
assert(PyUnicode_Check(rep));
@@ -6835,6 +6833,9 @@ unicode_encode_ucs1(PyObject *unicode,
68356833
PyUnicode_DATA(rep),
68366834
PyUnicode_GET_LENGTH(rep));
68376835
}
6836+
if (str == NULL)
6837+
goto onError;
6838+
68386839
pos = newpos;
68396840
Py_CLEAR(rep);
68406841
}

0 commit comments

Comments
 (0)