Browse Source

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>
tags/n0.9
Martin Storsjö 14 years ago
parent
commit
44729bc020
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      libavformat/matroskaenc.c

+ 7
- 3
libavformat/matroskaenc.c View File

@@ -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);



Loading…
Cancel
Save