aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-11-24 08:59:04 +0100
committerMax Kellermann <max@duempel.org>2010-11-24 08:59:04 +0100
commit429ed24c9903008c3699da48d353f48e1a3151f6 (patch)
treeff68574fb6cd398611ff0c733bc616a03bf1ed5e /src
parent1ab46472ab8fa38a87f18411820bb1dbd7f51990 (diff)
downloadmpd-429ed24c9903008c3699da48d353f48e1a3151f6.tar.gz
mpd-429ed24c9903008c3699da48d353f48e1a3151f6.tar.xz
mpd-429ed24c9903008c3699da48d353f48e1a3151f6.zip
tag_ape: support multiple values
One APE tag may contain more than one value, separated by null bytes.
Diffstat (limited to '')
-rw-r--r--src/tag_ape.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tag_ape.c b/src/tag_ape.c
index 82e36d7a4..79facba1b 100644
--- a/src/tag_ape.c
+++ b/src/tag_ape.c
@@ -52,7 +52,21 @@ tag_ape_import_item(struct tag *tag, unsigned long flags,
if (tag == NULL)
tag = tag_new();
- tag_add_item_n(tag, type, value, value_length);
+
+ const char *end = value + value_length;
+ while (true) {
+ /* multiple values are separated by null bytes */
+ const char *n = memchr(value, 0, end - value);
+ if (n != NULL) {
+ if (n > value)
+ tag_add_item_n(tag, type, value, n - value);
+ value = n + 1;
+ } else {
+ if (end > value)
+ tag_add_item_n(tag, type, value, end - value);
+ break;
+ }
+ }
return tag;
}