2019-01-07 Jonathan Wakely <jwakely@redhat.com>
+ 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.
+
* doc/xml/manual/spine.xml: Update copyright years.
* doc/xml/manual/status_cxx2017.xml: Adjust note about -lstdc++fs.
* doc/xml/manual/using.xml: Remove requirement to link with -lstdc++fs
{
if (_M_widen_ok == 1)
{
- __builtin_memcpy(__to, __lo, __hi - __lo);
+ if (__builtin_expect(__hi != __lo, true))
+ __builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
if (!_M_widen_ok)
{
if (__builtin_expect(_M_narrow_ok == 1, true))
{
- __builtin_memcpy(__to, __lo, __hi - __lo);
+ if (__builtin_expect(__hi != __lo, true))
+ __builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
if (!_M_narrow_ok)
virtual const char*
do_widen(const char* __lo, const char* __hi, char_type* __to) const
{
- __builtin_memcpy(__to, __lo, __hi - __lo);
+ if (__builtin_expect(__hi != __lo, true))
+ __builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
do_narrow(const char_type* __lo, const char_type* __hi,
char __dfault __attribute__((__unused__)), char* __to) const
{
- __builtin_memcpy(__to, __lo, __hi - __lo);
+ if (__builtin_expect(__hi != __lo, true))
+ __builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}