From: Alexey Izbyshev Date: Sun, 19 Aug 2018 18:52:04 +0000 (+0300) Subject: bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823) X-Git-Tag: v3.8.0a1~1190 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=74a307d48ef8b278c4629ca0ef2139be1c9a34e6;p=thirdparty%2FPython%2Fcpython.git bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823) Reported by Svace static analyzer. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 0460d184932e..087cfca58d36 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -6813,8 +6813,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)); @@ -6836,6 +6834,9 @@ unicode_encode_ucs1(PyObject *unicode, PyUnicode_DATA(rep), PyUnicode_GET_LENGTH(rep)); } + if (str == NULL) + goto onError; + pos = newpos; Py_CLEAR(rep); }