1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/matroskadec: Call matroska_read_close() on header parsing error

Fixes memleak
Fixes Ticket5169

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2016-06-24 18:26:46 +02:00
parent 84b252ba2a
commit f573acc424

View File

@ -733,6 +733,8 @@ static const EbmlSyntax matroska_clusters_incremental[] = {
static const char *const matroska_doctypes[] = { "matroska", "webm" }; static const char *const matroska_doctypes[] = { "matroska", "webm" };
static int matroska_read_close(AVFormatContext *s);
static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos) static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
{ {
AVIOContext *pb = matroska->ctx->pb; AVIOContext *pb = matroska->ctx->pb;
@ -2437,7 +2439,7 @@ static int matroska_read_header(AVFormatContext *s)
while (res != 1) { while (res != 1) {
res = matroska_resync(matroska, pos); res = matroska_resync(matroska, pos);
if (res < 0) if (res < 0)
return res; goto fail;
pos = avio_tell(matroska->ctx->pb); pos = avio_tell(matroska->ctx->pb);
res = ebml_parse(matroska, matroska_segment, matroska); res = ebml_parse(matroska, matroska_segment, matroska);
} }
@ -2456,7 +2458,7 @@ static int matroska_read_header(AVFormatContext *s)
res = matroska_parse_tracks(s); res = matroska_parse_tracks(s);
if (res < 0) if (res < 0)
return res; goto fail;
attachments = attachments_list->elem; attachments = attachments_list->elem;
for (j = 0; j < attachments_list->nb_elem; j++) { for (j = 0; j < attachments_list->nb_elem; j++) {
@ -2530,6 +2532,9 @@ static int matroska_read_header(AVFormatContext *s)
matroska_convert_tags(s); matroska_convert_tags(s);
return 0; return 0;
fail:
matroska_read_close(s);
return res;
} }
/* /*