The caller expects the seekhead struct to be freed when calling
matroska_write_seekhead. Currently, the structure is leaked if the
seek fails.
---
libavformat/matroskaenc.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 5edd2be..0667947 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -316,11 +316,14 @@ static int64_t mkv_write_seekhead(AVIOContext *pb,
mkv_seekhead *seekhead)
int i;
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++) {
mkv_seekhead_entry *entry = &seekhead->entries[i];
@@ -342,8 +345,9 @@ static int64_t mkv_write_seekhead(AVIOContext *pb,
mkv_seekhead *seekhead)
avio_seek(pb, currentpos, SEEK_SET);
currentpos = seekhead->filepos;
}
+fail:
av_free(seekhead->entries);
av_free(seekhead);
return currentpos;
--
1.7.3.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel