diff options
Diffstat (limited to 'libavformat/apetag.c')
-rw-r--r-- | libavformat/apetag.c | 17 |
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; } |