bpo-40998: Address compiler warnings found by ubsan (GH-20929)

Signed-off-by: Christian Heimes <christian@python.org>

Automerge-Triggered-By: GH:tiran
This commit is contained in:
Christian Heimes 2020-11-18 16:38:53 +01:00 committed by GitHub
parent 46f59ebd01
commit 07f2adedf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 5 deletions

View file

@ -839,7 +839,11 @@ xmlcharrefreplace(_PyBytesWriter *writer, char *str,
/* generate replacement */
for (i = collstart; i < collend; ++i) {
str += sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
size = sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
if (size < 0) {
return NULL;
}
str += size;
}
return str;
}