From f56ade7941df2ffd53ed013a3fca4a3560776b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Sun, 28 Oct 2018 19:54:29 -0400 Subject: [PATCH] delete_tags did not delete multiple tags correctly --- opustags.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opustags.c b/opustags.c index de118dc..6d3ee30 100644 --- a/opustags.c +++ b/opustags.c @@ -113,9 +113,13 @@ void delete_tags(opus_tags *tags, const char *field){ uint32_t i; for(i=0; icount; i++){ if(match_field(tags->comment[i], tags->lengths[i], field)){ + // We want to delete the current element, so we move the last tag at position i, then + // decrease the array size. We need decrease i to inspect at the next iteration the tag + // we just moved. tags->count--; tags->lengths[i] = tags->lengths[tags->count]; tags->comment[i] = tags->comment[tags->count]; + --i; // No need to resize the arrays. } }