gh-111089: PyUnicode_AsUTF8AndSize() sets size on error (#111106)

On error, PyUnicode_AsUTF8AndSize() now sets the size argument to -1,
to avoid undefined value.
This commit is contained in:
Victor Stinner 2023-10-20 20:03:11 +02:00 committed by GitHub
parent d8f32be5b6
commit f1e751e933
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View file

@ -634,7 +634,7 @@ unicode_asutf8andsize(PyObject *self, PyObject *args)
NULLABLE(unicode);
s = PyUnicode_AsUTF8AndSize(unicode, &size);
if (s == NULL) {
assert(size == UNINITIALIZED_SIZE);
assert(size == -1);
return NULL;
}