diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2018-05-14 16:35:06 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2018-05-14 16:35:06 +0100 |
commit | 6bfbebb063100f6ab845a8456fc7fec99361da80 (patch) | |
tree | ca6814e6e58a7b580db228d60d76bb17ba9ac995 | |
parent | 9f613f06b0da4b11cde815351df31ad74e22f449 (diff) | |
download | gcc-6bfbebb063100f6ab845a8456fc7fec99361da80.zip gcc-6bfbebb063100f6ab845a8456fc7fec99361da80.tar.gz gcc-6bfbebb063100f6ab845a8456fc7fec99361da80.tar.bz2 |
PR libstdc++/67554 Do not pass null pointers to memcpy
PR libstdc++/67554
* include/bits/valarray_array.h (_Array_copy_ctor<_Tp, true>)
(_Array_copier<_Tp, true>): Do not pass null pointers to memcpy.
From-SVN: r260229
-rw-r--r-- | libstdc++-v3/ChangeLog | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/valarray_array.h | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2c0c0d4..9d47d00 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2018-05-14 Jonathan Wakely <jwakely@redhat.com> + PR libstdc++/67554 + * include/bits/valarray_array.h (_Array_copy_ctor<_Tp, true>) + (_Array_copier<_Tp, true>): Do not pass null pointers to memcpy. + PR libstdc++/82966 * include/bits/node_handle.h (_Node_handle_common::_M_swap): Use value instead of type. diff --git a/libstdc++-v3/include/bits/valarray_array.h b/libstdc++-v3/include/bits/valarray_array.h index f1d2c43..07f38ed 100644 --- a/libstdc++-v3/include/bits/valarray_array.h +++ b/libstdc++-v3/include/bits/valarray_array.h @@ -152,7 +152,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { inline static void _S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o) - { __builtin_memcpy(__o, __b, (__e - __b) * sizeof(_Tp)); } + { + if (__b) + __builtin_memcpy(__o, __b, (__e - __b) * sizeof(_Tp)); + } }; template<typename _Tp> @@ -258,7 +261,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { inline static void _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) - { __builtin_memcpy(__b, __a, __n * sizeof (_Tp)); } + { + if (__n != 0) + __builtin_memcpy(__b, __a, __n * sizeof (_Tp)); + } }; // Copy a plain array __a[<__n>] into a play array __b[<>] |