diff options
author | Max Kellermann <max@musicpd.org> | 2021-04-15 16:13:27 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-04-15 16:15:44 +0200 |
commit | 650a30d7940fd395bc664558ead883a6ada918a7 (patch) | |
tree | f019b09ddcce88a12983afef6e0a8f4a6a03d17a /src | |
parent | 1dc71f383ac9f6a259b3e78199236e4ba8fb8f40 (diff) |
Revert "tag/Pool: use strncmp() without strlen() to compare strings"
This reverts commit 1532983fb5755305a86fc37d2f35a7757d2bd66f. This
optimization was bad because now all strings match if they are a
prefix of another string, and this caused collisions in the tag string
pool, corrupting the database.
Diffstat (limited to 'src')
-rw-r--r-- | src/tag/Pool.cxx | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/tag/Pool.cxx b/src/tag/Pool.cxx index e977c6784..e5a6d57f2 100644 --- a/src/tag/Pool.cxx +++ b/src/tag/Pool.cxx @@ -114,10 +114,7 @@ tag_pool_get_item(TagType type, StringView value) noexcept auto slot_p = tag_value_slot_p(type, value); for (auto slot = *slot_p; slot != nullptr; slot = slot->next) { if (slot->item.type == type && - /* strncmp() only works if there are no null - bytes, which FixTagString() has already ensured - at this point */ - strncmp(value.data, slot->item.value, value.size) == 0 && + value.Equals(slot->item.value) && slot->ref < TagPoolSlot::MAX_REF) { assert(slot->ref > 0); ++slot->ref; |