PR libstdc++/87787 avoid undefined null args to memcpy and memmove
authorJonathan Wakely <jwakely@redhat.com>
Mon, 7 Jan 2019 14:58:44 +0000 (14:58 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 7 Jan 2019 14:58:44 +0000 (14:58 +0000)
commite002afaa8e01395110c77de18bb7e0fa030ba019
tree203a73ef36a0dbf4ceb00a25c30b1bcfdafabcb2
parenta58fe3c5ca1f0101c4af7f0c5b860cc4d49cd4cb
PR libstdc++/87787 avoid undefined null args to memcpy and memmove

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<char>::widen(const char*, const char*, char*)): Do not
pass null pointers to memcpy.
(ctype<char>::narrow(const char*, const char*, char, char*)):
Likewise.
(ctype<char>::do_widen(const char*, const char*, char*)):
Likewise.
(ctype<char>::do_narrow(const char*, const char*, char, char*)):
Likewise.

From-SVN: r267651
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/char_traits.h
libstdc++-v3/include/bits/locale_facets.h