diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-09-11 12:13:44 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-09-11 12:16:21 +0200 |
commit | c9367c07091b7e89964af71ffca8f24891b61284 (patch) | |
tree | aaad22b53771235123a2c1e1510fa974e1392d24 /libavformat/matroskaenc.c | |
parent | 32805f852116f792b85635680a804b10edf26210 (diff) | |
download | ffmpeg-c9367c07091b7e89964af71ffca8f24891b61284.tar.gz |
avformat/matroskaenc: functions that add entries should not destroy the whole list on failure
This reverts a hunk from "avformat: Use av_reallocp_array() where suitable"
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r-- | libavformat/matroskaenc.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c6541b2da1..13523f800f 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -302,17 +302,14 @@ static mkv_seekhead * mkv_start_seekhead(AVIOContext *pb, int64_t segment_offset static int mkv_add_seekhead_entry(mkv_seekhead *seekhead, unsigned int elementid, uint64_t filepos) { mkv_seekhead_entry *entries = seekhead->entries; - int err; // don't store more elements than we reserved space for if (seekhead->max_entries > 0 && seekhead->max_entries <= seekhead->num_entries) return -1; - if ((err = av_reallocp_array(&entries, seekhead->num_entries + 1, - sizeof(*entries))) < 0) { - seekhead->num_entries = 0; - return err; - } + entries = av_realloc(entries, (seekhead->num_entries + 1) * sizeof(mkv_seekhead_entry)); + if (entries == NULL) + return AVERROR(ENOMEM); entries[seekhead->num_entries ].elementid = elementid; entries[seekhead->num_entries++].segmentpos = filepos - seekhead->segment_offset; @@ -387,16 +384,13 @@ static mkv_cues * mkv_start_cues(int64_t segment_offset) static int mkv_add_cuepoint(mkv_cues *cues, int stream, int64_t ts, int64_t cluster_pos, int64_t relative_pos) { mkv_cuepoint *entries = cues->entries; - int err; if (ts < 0) return 0; - if ((err = av_reallocp_array(&entries, cues->num_entries + 1, - sizeof(*entries))) < 0) { - cues->num_entries = 0; - return err; - } + entries = av_realloc(entries, (cues->num_entries + 1) * sizeof(mkv_cuepoint)); + if (entries == NULL) + return AVERROR(ENOMEM); entries[cues->num_entries ].pts = ts; entries[cues->num_entries ].tracknum = stream + 1; |