re PR libstdc++/66354 ([UBSAN] stl_algobase.h:708:7: runtime error: null pointer passed as argument)

PR libstdc++/66354
	* include/bits/stl_algobase.h (__fill_a): Check length before calling
	memset.

From-SVN: r223906
This commit is contained in:
Jonathan Wakely 2015-05-31 23:42:17 +01:00 committed by Jonathan Wakely
parent 1edfb384e8
commit 5d946f4228
2 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2015-05-31 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/66354
* include/bits/stl_algobase.h (__fill_a): Check length before calling
memset.
2015-05-30 Jonathan Wakely <jwakely@redhat.com> 2015-05-30 Jonathan Wakely <jwakely@redhat.com>
* include/bits/stl_algobase.h (__equal<true>::equal): Check length * include/bits/stl_algobase.h (__equal<true>::equal): Check length

View File

@ -705,8 +705,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__fill_a(_Tp* __first, _Tp* __last, const _Tp& __c) __fill_a(_Tp* __first, _Tp* __last, const _Tp& __c)
{ {
const _Tp __tmp = __c; const _Tp __tmp = __c;
__builtin_memset(__first, static_cast<unsigned char>(__tmp), if (const size_t __len = __last - __first)
__last - __first); __builtin_memset(__first, static_cast<unsigned char>(__tmp), __len);
} }
/** /**