summaryrefslogtreecommitdiff
path: root/libavformat/apetag.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-12-13 20:27:29 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-12-13 20:27:29 +0000
commit12ad66712a18d039eea73a742ae626b2376f8f4f (patch)
treef6d863c1a428480ad0366d48c44c8b89ef53b3e3 /libavformat/apetag.c
parentb8f11ec8878641f699c07b8425079d3611a51072 (diff)
Use AV_METADATA_DONT_STRDUP* / use av_malloced metadata instead of strduped
arrays of fixed length. Code from ffmbc with changes to adapt to our metadata API. Originally committed as revision 20836 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/apetag.c')
-rw-r--r--libavformat/apetag.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 262270cd42..bc91507c87 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -33,7 +33,7 @@
static int ape_tag_read_field(AVFormatContext *s)
{
ByteIOContext *pb = s->pb;
- uint8_t key[1024], value[1024];
+ uint8_t key[1024], *value;
uint32_t size, flags;
int i, l, c;
@@ -51,13 +51,14 @@ static int ape_tag_read_field(AVFormatContext *s)
av_log(s, AV_LOG_WARNING, "Invalid APE tag key '%s'.\n", key);
return -1;
}
- l = FFMIN(size, sizeof(value)-1);
- get_buffer(pb, value, l);
- value[l] = 0;
- url_fskip(pb, size-l);
- if (l < size)
- av_log(s, AV_LOG_WARNING, "Too long '%s' tag was truncated.\n", key);
- av_metadata_set(&s->metadata, key, value);
+ if (size >= UINT_MAX)
+ return -1;
+ value = av_malloc(size+1);
+ if (!value)
+ return AVERROR_NOMEM;
+ get_buffer(pb, value, size);
+ value[size] = 0;
+ av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
return 0;
}