History

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.

Martin Storsjö committed 15 years ago

Commit 44729bc1 parent 090aaaf1 file · +7 −3Browse files

Unified · Split

libavformat/matroskaenc.c+7−3
@@ -317,9 +317,12 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead) · 316 unmodified lines
317317
318318 currentpos = avio_tell(pb);
319319
320− if (seekhead->reserved_size > 0)
321− if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0)
322− return -1;
320+ if (seekhead->reserved_size > 0) {
321+ if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
322+ currentpos = -1;
323+ goto fail;
324+ }
325+ }
323326
324327 metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);
325328 for (i = 0; i < seekhead->num_entries; i++) {
@@ -343,6 +346,7 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead) · 17 unmodified lines
343346
344347 currentpos = seekhead->filepos;
345348 }
349+fail:
346350 av_free(seekhead->entries);
347351 av_free(seekhead);
348352

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t