summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index fe49ec8..388734e 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -497,6 +497,13 @@ PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u,
PyObject *PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
{
PyUnicodeObject *unicode;
+
+ if (size < 0) {
+ PyErr_SetString(PyExc_SystemError,
+ "Negative size passed to PyUnicode_FromStringAndSize");
+ return NULL;
+ }
+
/* If the Unicode data is known at construction time, we can apply
some optimizations which share commonly used objects.
Also, this means the input must be UTF-8, so fall back to the