avformat/wc3movie: fix memleak when read content size not equvipe input size

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
This commit is contained in:
Steven Liu 2019-10-10 10:07:56 +08:00
parent 70c6e84069
commit 68f623d644

View File

@ -130,8 +130,10 @@ static int wc3_read_header(AVFormatContext *s)
buffer = av_malloc(size+1); buffer = av_malloc(size+1);
if (!buffer) if (!buffer)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if ((ret = avio_read(pb, buffer, size)) != size) if ((ret = avio_read(pb, buffer, size)) != size) {
av_freep(&buffer);
return AVERROR(EIO); return AVERROR(EIO);
}
buffer[size] = 0; buffer[size] = 0;
av_dict_set(&s->metadata, "title", buffer, av_dict_set(&s->metadata, "title", buffer,
AV_DICT_DONT_STRDUP_VAL); AV_DICT_DONT_STRDUP_VAL);