Skip to content

Commit 74a307d

Browse files
izbyshevserhiy-storchaka
authored andcommitted
bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823)
Reported by Svace static analyzer.
1 parent 225b055 commit 74a307d

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
@@ -6813,8 +6813,6 @@ unicode_encode_ucs1(PyObject *unicode,
68136813
str = _PyBytesWriter_WriteBytes(&writer, str,
68146814
PyBytes_AS_STRING(rep),
68156815
PyBytes_GET_SIZE(rep));
6816-
if (str == NULL)
6817-
goto onError;
68186816
}
68196817
else {
68206818
assert(PyUnicode_Check(rep));
@@ -6836,6 +6834,9 @@ unicode_encode_ucs1(PyObject *unicode,
68366834
PyUnicode_DATA(rep),
68376835
PyUnicode_GET_LENGTH(rep));
68386836
}
6837+
if (str == NULL)
6838+
goto onError;
6839+
68396840
pos = newpos;
68406841
Py_CLEAR(rep);
68416842
}

0 commit comments

Comments
 (0)