The C++ char_traits and ctype APIs do not disallow null pointer arguments, so we need explicit checks to ensure we don't forward null pointers to memcpy or memmove. PR libstdc++/87787 * include/bits/char_traits.h (char_traits::move): Do not pass null pointers to memmove. * include/bits/locale_facets.h (ctype::widen(const char*, const char*, char*)): Do not pass null pointers to memcpy. (ctype::narrow(const char*, const char*, char, char*)): Likewise. (ctype::do_widen(const char*, const char*, char*)): Likewise. (ctype::do_narrow(const char*, const char*, char, char*)): Likewise. Tested powerpc64-linux, committed to trunk.