aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2020-11-18 16:38:53 +0100
committerGitHub <noreply@github.com>2020-11-18 07:38:53 -0800
commit07f2adedf0940b06d136208ec386d69b7d2d5b43 (patch)
treed0b64e336c25ed40ca94e70f3363a31b633136a6 /Objects
parentbpo-1635741: Port _hashlib to multiphase initialization (GH-23358) (diff)
downloadcpython-07f2adedf0940b06d136208ec386d69b7d2d5b43.tar.gz
cpython-07f2adedf0940b06d136208ec386d69b7d2d5b43.tar.bz2
cpython-07f2adedf0940b06d136208ec386d69b7d2d5b43.zip
bpo-40998: Address compiler warnings found by ubsan (GH-20929)
Signed-off-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: GH:tiran
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index e7a63e7b973..70688c8c013 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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;
}