[FFmpeg-cvslog] matroskaenc: check cue point validity before reallocation

Janne Grunau git at videolan.org
Wed Oct 10 13:23:58 CEST 2012


ffmpeg | branch: master | Janne Grunau <janne-libav at jannau.net> | Tue Oct  9 14:54:01 2012 +0200| [4ffbe3f3a5d9892841d9bc31d859916c2c61123f] | committer: Janne Grunau

matroskaenc: check cue point validity before reallocation

Prevents memory leak and possible access to freed memory.
Fixes CID605744.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ffbe3f3a5d9892841d9bc31d859916c2c61123f
---

 libavformat/matroskaenc.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 3e32943..b37d10c 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -368,13 +368,13 @@ static int mkv_add_cuepoint(mkv_cues *cues, int stream, int64_t ts, int64_t clus
 {
     mkv_cuepoint *entries = cues->entries;
 
+    if (ts < 0)
+        return 0;
+
     entries = av_realloc(entries, (cues->num_entries + 1) * sizeof(mkv_cuepoint));
     if (entries == NULL)
         return AVERROR(ENOMEM);
 
-    if (ts < 0)
-        return 0;
-
     entries[cues->num_entries  ].pts = ts;
     entries[cues->num_entries  ].tracknum = stream + 1;
     entries[cues->num_entries++].cluster_pos = cluster_pos - cues->segment_offset;



More information about the ffmpeg-cvslog mailing list