aboutsummaryrefslogtreecommitdiffstats
path: root/src/metadataChunk.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-06 20:34:00 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-06 20:34:00 +0000
commit81720da06dbcaa156bab5d3283df0faaa0334b63 (patch)
tree17b7316462528c5f4c903b8179053d3f792990bc /src/metadataChunk.c
parentb29f73c819ff8445b71963d883364e315b7a12d8 (diff)
downloadmpd-81720da06dbcaa156bab5d3283df0faaa0334b63.tar.gz
mpd-81720da06dbcaa156bab5d3283df0faaa0334b63.tar.xz
mpd-81720da06dbcaa156bab5d3283df0faaa0334b63.zip
slightly safer copying of metadataChunk to MpdTag
git-svn-id: https://svn.musicpd.org/mpd/trunk@1359 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/metadataChunk.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/metadataChunk.c b/src/metadataChunk.c
index 1deab3d90..9a4c35e10 100644
--- a/src/metadataChunk.c
+++ b/src/metadataChunk.c
@@ -11,13 +11,21 @@ void initMetadataChunk(MetadataChunk * chunk) {
chunk->title = -1;
}
+#define dupElementToTag(string, element) { \
+ if(element >= 0 && element < METADATA_BUFFER_LENGTH) { \
+ string = strdup(chunk->buffer+element); \
+ } \
+}
+
MpdTag * metadataChunkToMpdTagDup(MetadataChunk * chunk) {
MpdTag * ret = newMpdTag();
- if(chunk->name >= 0) ret->name = strdup(chunk->buffer+chunk->name);
- if(chunk->artist >= 0) ret->artist = strdup(chunk->buffer+chunk->artist);
- if(chunk->album >= 0) ret->album = strdup(chunk->buffer+chunk->album);
- if(chunk->title >= 0) ret->title = strdup(chunk->buffer+chunk->title);
+ chunk->buffer[METADATA_BUFFER_LENGTH] = '\0';
+
+ dupElementToTag(ret->name, chunk->name);
+ dupElementToTag(ret->title, chunk->title);
+ dupElementToTag(ret->artist, chunk->artist);
+ dupElementToTag(ret->album, chunk->album);
return ret;
}