[FFmpeg-devel] [PATCH 05/12] asf: replace VLA with malloc/free

Mans Rullgard mans
Wed Jun 23 19:26:43 CEST 2010


---
 libavformat/asfdec.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index eb14146..025a00b 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1053,7 +1053,10 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos,
     int64_t pts;
     int64_t pos= *ppos;
     int i;
-    int64_t start_pos[s->nb_streams];
+    int64_t *start_pos = av_malloc(s->nb_streams * sizeof(*start_pos));
+
+    if (!start_pos)
+        return AV_NOPTS_VALUE;
 
     for(i=0; i<s->nb_streams; i++){
         start_pos[i]= pos;
@@ -1069,7 +1072,8 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos,
     for(;;){
         if (av_read_frame(s, pkt) < 0){
             av_log(s, AV_LOG_INFO, "asf_read_pts failed\n");
-            return AV_NOPTS_VALUE;
+            pts = AV_NOPTS_VALUE;
+            goto end;
         }
 
         pts= pkt->pts;
@@ -1094,6 +1098,8 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos,
     *ppos= pos;
 //printf("found keyframe at %"PRId64" stream %d stamp:%"PRId64"\n", *ppos, stream_index, pts);
 
+end:
+    av_free(start_pos);
     return pts;
 }
 
-- 
1.7.1




More information about the ffmpeg-devel mailing list