From abb28593ce3a5c176123edfe7729e6d8c379903a Mon Sep 17 00:00:00 2001 From: gd Date: Tue, 8 Nov 2022 21:45:55 +0200 Subject: [PATCH] TagBuilder::RemoveType: added missing tag pool lock before call to tag_pool_put_item --- NEWS | 2 ++ src/tag/Builder.cxx | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/NEWS b/NEWS index aaa79ed7e..84f657064 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.23.12 (not yet released) +* tags + - fix crash bug due to race condition ver 0.23.11 (2022/11/28) * database diff --git a/src/tag/Builder.cxx b/src/tag/Builder.cxx index 468d3d676..0876dcf95 100644 --- a/src/tag/Builder.cxx +++ b/src/tag/Builder.cxx @@ -263,8 +263,14 @@ TagBuilder::RemoveAll() noexcept void TagBuilder::RemoveType(TagType type) noexcept { + if (items.empty()) + /* don't acquire the tag_pool_lock if we're not going + to call tag_pool_put_item() anyway */ + return; + const auto begin = items.begin(), end = items.end(); + const std::scoped_lock protect(tag_pool_lock); items.erase(std::remove_if(begin, end, [type](TagItem *item) { if (item->type != type)