Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-40998: Address compiler warnings found by ubsan
Signed-off-by: Christian Heimes <christian@python.org>
  • Loading branch information
tiran committed Nov 18, 2020
commit 62c99cd96bcb1015636048b0e422827735af0959
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Addressed three compiler warnings found by undefined behavior sanitizer
(ubsan).
6 changes: 5 additions & 1 deletion Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions Parser/string_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t)
return NULL;
}
p = buf = PyBytes_AsString(u);
if (p == NULL) {
return NULL;
}
end = s + len;
while (s < end) {
if (*s == '\\') {
Expand Down
2 changes: 2 additions & 0 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,9 @@ Py_FinalizeEx(void)

/* Get current thread state and interpreter pointer */
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
#if (defined(Py_REF_DEBUG) || defined(Py_TRACE_REFS) || defined(WITH_PYMALLOC))
Comment thread
tiran marked this conversation as resolved.
Outdated
PyInterpreterState *interp = tstate->interp;
#endif

// Wrap up existing "threading"-module-created, non-daemon threads.
wait_for_thread_shutdown(tstate);
Expand Down