summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 07d1b6e..80b1956 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3820,17 +3820,24 @@ PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize)
{
if (!PyUnicode_Check(unicode)) {
PyErr_BadArgument();
+ if (psize) {
+ *psize = -1;
+ }
return NULL;
}
if (PyUnicode_UTF8(unicode) == NULL) {
if (unicode_fill_utf8(unicode) == -1) {
+ if (psize) {
+ *psize = -1;
+ }
return NULL;
}
}
- if (psize)
+ if (psize) {
*psize = PyUnicode_UTF8_LENGTH(unicode);
+ }
return PyUnicode_UTF8(unicode);
}