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
317 317
318 currentpos = avio_tell(pb);318 currentpos = avio_tell(pb);
319 319
320 if (seekhead->reserved_size > 0)320 if (seekhead->reserved_size > 0) {
321 if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0)321 if (avio_seek(pb, seekhead->filepos, SEEK_SET) < 0) {
322 return -1;322 currentpos = -1;
323 goto fail;
324 }
325 }
323 326
324 metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);327 metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size);
325 for (i = 0; i < seekhead->num_entries; i++) {328 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
343 346
344 currentpos = seekhead->filepos;347 currentpos = seekhead->filepos;
345 }348 }
349fail:
346 av_free(seekhead->entries);350 av_free(seekhead->entries);
347 av_free(seekhead);351 av_free(seekhead);
348 352

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