The caller expects the seekhead struct to be freed when calling matroska_write_seekhead. Currently, the structure is leaked if the seek fails.
Unified · Split
| @@ -317,9 +317,12 @@ static int64_t mkv_write_seekhead(AVIOContext *pb, mkv_seekhead *seekhead) · 316 unmodified lines | ||
| 317 | 317 | |
| 318 | 318 | currentpos = avio_tell(pb); |
| 319 | 319 | |
| 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 | + } | |
| 323 | 326 | |
| 324 | 327 | metaseek = start_ebml_master(pb, MATROSKA_ID_SEEKHEAD, seekhead->reserved_size); |
| 325 | 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 | 347 | currentpos = seekhead->filepos; |
| 345 | 348 | } |
| 349 | +fail: | |
| 346 | 350 | av_free(seekhead->entries); |
| 347 | 351 | av_free(seekhead); |
| 348 | 352 | |