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/wc3movie.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'libavformat/wc3movie.c') diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c index 5369057dd4..502ff52564 100644 --- a/libavformat/wc3movie.c +++ b/libavformat/wc3movie.c @@ -140,10 +140,9 @@ static int wc3_read_header(AVFormatContext *s, unsigned int fourcc_tag; unsigned int size; AVStream *st; - char buffer[513]; int ret = 0; int current_palette = 0; - int bytes_to_read; + char *buffer; int i; unsigned char rotate; @@ -185,14 +184,14 @@ static int wc3_read_header(AVFormatContext *s, case BNAM_TAG: /* load up the name */ - if ((unsigned)size < 512) - bytes_to_read = size; - else - bytes_to_read = 512; - if ((ret = get_buffer(pb, buffer, bytes_to_read)) != bytes_to_read) + buffer = av_malloc(size+1); + if (!buffer) + return AVERROR_NOMEM; + if ((ret = get_buffer(pb, buffer, size)) != size) return AVERROR(EIO); - buffer[bytes_to_read] = 0; - av_metadata_set(&s->metadata, "title", buffer); + buffer[size] = 0; + av_metadata_set2(&s->metadata, "title", buffer, + AV_METADATA_DONT_STRDUP_VAL); break; case SIZE_TAG: -- cgit v1.2.3