Revert "tag/Pool: use strncmp() without strlen() to compare strings"
This reverts commit 1532983fb5
. 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.
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user