From 44f55e1866cdfc50d1a046040df8405d171af80d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 11 Sep 2023 21:14:39 +0200 Subject: [PATCH] util/IntrusiveList: add missing initializer to insert_after() We must not call std::next() if the list head was not yet initialized. This was missing in commit 70654259270fdaae2906fb9fe4f34c6e3a740c37 --- src/util/IntrusiveList.hxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/IntrusiveList.hxx b/src/util/IntrusiveList.hxx index e5af95e16..a004759a0 100644 --- a/src/util/IntrusiveList.hxx +++ b/src/util/IntrusiveList.hxx @@ -538,6 +538,10 @@ public: * Like insert(), but insert after the given position. */ void insert_after(iterator p, reference t) noexcept { + if constexpr (options.zero_initialized) + if (head.next == nullptr) + head = {&head, &head}; + insert(std::next(p), t); }