Skip to content

Commit e77cdae

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 f19579b commit e77cdae

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
@@ -6903,8 +6903,6 @@ unicode_encode_ucs1(PyObject *unicode,
69036903
str = _PyBytesWriter_WriteBytes(&writer, str,
69046904
PyBytes_AS_STRING(rep),
69056905
PyBytes_GET_SIZE(rep));
6906-
if (str == NULL)
6907-
goto onError;
69086906
}
69096907
else {
69106908
assert(PyUnicode_Check(rep));
@@ -6940,6 +6938,9 @@ unicode_encode_ucs1(PyObject *unicode,
69406938
}
69416939
}
69426940
}
6941+
if (str == NULL)
6942+
goto onError;
6943+
69436944
pos = newpos;
69446945
Py_CLEAR(rep);
69456946
}

0 commit comments

Comments
 (0)