From 12ad66712a18d039eea73a742ae626b2376f8f4f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 13 Dec 2009 20:27:29 +0000 Subject: 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 --- libavformat/apetag.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'libavformat/apetag.c') 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; } -- cgit v1.2.3