summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-08-19 16:17:53 -0400
committerGitHub <noreply@github.com>2018-08-19 16:17:53 -0400
commit1e596d3a20a1a9d1ef15218ef33795bc9e651b7a (patch)
treeca40a695e4eb1fdf4c426c21aaf69c0c64bb75e4 /Objects/unicodeobject.c
parentbpo-22057: Clarify eval() documentation (GH-8812) (diff)
downloadcpython-1e596d3a20a1a9d1ef15218ef33795bc9e651b7a.tar.gz
cpython-1e596d3a20a1a9d1ef15218ef33795bc9e651b7a.tar.bz2
cpython-1e596d3a20a1a9d1ef15218ef33795bc9e651b7a.zip
bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823)
Reported by Svace static analyzer. (cherry picked from commit 74a307d48ef8b278c4629ca0ef2139be1c9a34e6) Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 5d605abd032..fe833a76ead 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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);
}