diff options
author | Martin Storsjö <martin@martin.st> | 2011-11-07 21:06:01 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2011-11-07 22:23:17 +0200 |
commit | 44729bc0204fd8bdc29c234fc663229e44420b09 (patch) | |
tree | b00ffd85ecae01f8d17b9204a6412a05a99951e9 | |
parent | 090aaaf75280ed42a5e5c7424c366d5b6bab8dde (diff) | |
download | ffmpeg-44729bc0204fd8bdc29c234fc663229e44420b09.tar.gz |
matroskaenc: Make sure the seekhead struct is freed even on seek failure
The caller expects the seekhead struct to be freed when calling
matroska_write_seekhead. Currently, the structure is leaked if the
seek fails.
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | libavformat/matroskaenc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 5edd2be91c..0667947e09 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -317,9 +317,12 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead) currentpos = avio_tell(pb); - if (seekhead->reserved_size > 0) - if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) - return -1; + if (seekhead->reserved_size > 0) { + if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) { + currentpos = -1; + goto fail; + } + } metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size); for (i = 0; i < seekhead->num_entries; i++) { @@ -343,6 +346,7 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead) currentpos = seekhead->filepos; } +fail: av_free(seekhead->entries); av_free(seekhead); |