From 81efed752df3a07ce187f13667a05fe141075a29 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 6 Feb 2025 09:02:39 +1100 Subject: Feature [feature-requests:#1540]. Avoid memory leaks caused by addition of uninitialized_value_construct_n by using loop in InsertEmpty. --- src/SplitVector.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SplitVector.h b/src/SplitVector.h index 081c7cbfb..d46156e27 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -211,7 +211,10 @@ public: RoomFor(insertLength); GapTo(position); T *ptr = body.data() + part1Length; - std::uninitialized_value_construct_n(ptr, insertLength); + for (ptrdiff_t elem = 0; elem < insertLength; elem++, ptr++) { + T emptyOne = {}; + *ptr = std::move(emptyOne); + } lengthBody += insertLength; part1Length += insertLength; gapLength -= insertLength; -- cgit v1.2.3