* [committed] libstdc++: Fix size passed to operator delete [PR108097]
@ 2022-12-14 14:11 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-12-14 14:11 UTC (permalink / raw)
To: libstdc++, gcc-patches
Tested x86_64-linux. Pushed to trunk.
-- >8 --
The number of elements gets stored in _M_capacity so use a separate
variable for the number of bytes to allocate.
libstdc++-v3/ChangeLog:
PR libstdc++/108097
* include/std/stacktrace (basic_stracktrace::_Impl): Do not
multiply N by sizeof(value_type) when allocating.
---
libstdc++-v3/include/std/stacktrace | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace
index 83c6463b0d8..402be3e828e 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -608,8 +608,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
if constexpr (is_same_v<allocator_type, allocator<value_type>>)
{
- __n *= sizeof(value_type);
- void* const __p = _GLIBCXX_OPERATOR_NEW (__n, nothrow_t{});
+ // For std::allocator we use nothrow-new directly so we
+ // don't need to handle bad_alloc exceptions.
+ size_t __nb = __n * sizeof(value_type);
+ void* const __p = _GLIBCXX_OPERATOR_NEW (__nb, nothrow_t{});
if (__p == nullptr) [[unlikely]]
return nullptr;
_M_frames = static_cast<pointer>(__p);
--
2.38.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-14 14:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 14:11 [committed] libstdc++: Fix size passed to operator delete [PR108097] Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).