[FFmpeg-devel] [PATCH 2/3] proresdec2: Replace a VLA with a heap alloc

Derek Buitenhuis derek.buitenhuis at gmail.com
Fri Sep 7 16:38:16 CEST 2012


Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
 libavcodec/proresdec2.c |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index 0e32a97..6d141e2 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -500,13 +500,24 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
 static int decode_picture(AVCodecContext *avctx)
 {
     ProresContext *ctx = avctx->priv_data;
-    int i, threads_ret[ctx->slice_count];
+    int i, ret;
+    int *threads_ret;
+
+    threads_ret = av_malloc(ctx->slice_count * sizeof(*threads_ret));
+    if (!threads_ret)
+        return AVERROR(ENOMEM);
 
     avctx->execute2(avctx, decode_slice_thread, NULL, threads_ret, ctx->slice_count);
 
-    for (i = 0; i < ctx->slice_count; i++)
-        if (threads_ret[i] < 0)
-            return threads_ret[i];
+    for (i = 0; i < ctx->slice_count; i++) {
+        if (threads_ret[i] < 0) {
+            ret = threads_ret[i];
+            av_freep(&threads_ret);
+            return ret;
+        }
+    }
+
+    av_freep(&threads_ret);
 
     return 0;
 }
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list