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/vqf.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'libavformat/vqf.c') diff --git a/libavformat/vqf.c b/libavformat/vqf.c index d2b48dda04..40fea47157 100644 --- a/libavformat/vqf.c +++ b/libavformat/vqf.c @@ -45,15 +45,18 @@ static int vqf_probe(AVProbeData *probe_packet) static void add_metadata(AVFormatContext *s, const char *tag, unsigned int tag_len, unsigned int remaining) { - char buf[2048]; - int len = FFMIN3(tag_len, remaining, sizeof(buf) - 1); + int len = FFMIN(tag_len, remaining); + char *buf; - if (len != tag_len) - av_log(s, AV_LOG_ERROR, "Warning: truncating metadata!\n"); + if (len == UINT_MAX) + return; + buf = av_malloc(len+1); + if (!buf) + return; get_buffer(s->pb, buf, len); buf[len] = 0; - av_metadata_set(&s->metadata, tag, buf); + av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL); } static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap) -- cgit v1.2.3