mirror of https://github.com/python/cpython
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:
parent
46f59ebd01
commit
07f2adedf0
|
@ -0,0 +1,2 @@
|
||||||
|
Addressed three compiler warnings found by undefined behavior sanitizer
|
||||||
|
(ubsan).
|
|
@ -839,7 +839,11 @@ xmlcharrefreplace(_PyBytesWriter *writer, char *str,
|
||||||
|
|
||||||
/* generate replacement */
|
/* generate replacement */
|
||||||
for (i = collstart; i < collend; ++i) {
|
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;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,9 @@ decode_unicode_with_escapes(Parser *parser, const char *s, size_t len, Token *t)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = buf = PyBytes_AsString(u);
|
p = buf = PyBytes_AsString(u);
|
||||||
|
if (p == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
end = s + len;
|
end = s + len;
|
||||||
while (s < end) {
|
while (s < end) {
|
||||||
if (*s == '\\') {
|
if (*s == '\\') {
|
||||||
|
|
|
@ -1644,7 +1644,6 @@ Py_FinalizeEx(void)
|
||||||
|
|
||||||
/* Get current thread state and interpreter pointer */
|
/* Get current thread state and interpreter pointer */
|
||||||
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
||||||
PyInterpreterState *interp = tstate->interp;
|
|
||||||
|
|
||||||
// Wrap up existing "threading"-module-created, non-daemon threads.
|
// Wrap up existing "threading"-module-created, non-daemon threads.
|
||||||
wait_for_thread_shutdown(tstate);
|
wait_for_thread_shutdown(tstate);
|
||||||
|
@ -1667,13 +1666,13 @@ Py_FinalizeEx(void)
|
||||||
/* Copy the core config, PyInterpreterState_Delete() free
|
/* Copy the core config, PyInterpreterState_Delete() free
|
||||||
the core config memory */
|
the core config memory */
|
||||||
#ifdef Py_REF_DEBUG
|
#ifdef Py_REF_DEBUG
|
||||||
int show_ref_count = interp->config.show_ref_count;
|
int show_ref_count = tstate->interp->config.show_ref_count;
|
||||||
#endif
|
#endif
|
||||||
#ifdef Py_TRACE_REFS
|
#ifdef Py_TRACE_REFS
|
||||||
int dump_refs = interp->config.dump_refs;
|
int dump_refs = tstate->interp->config.dump_refs;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_PYMALLOC
|
#ifdef WITH_PYMALLOC
|
||||||
int malloc_stats = interp->config.malloc_stats;
|
int malloc_stats = tstate->interp->config.malloc_stats;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Remaining daemon threads will automatically exit
|
/* Remaining daemon threads will automatically exit
|
||||||
|
|
Loading…
Reference in New Issue