From d66c7abc937069d57fb156bcecec16e406b88c7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sylvain=20Corr=C3=A9?= <sylvain.corre@wanadoo.fr>
Date: Thu, 20 Mar 2003 01:32:17 +0000
Subject: [PATCH] =?UTF-8?q?MacOS=20X=20stack=20overflow=3F=20patch=20by=20?=
 =?UTF-8?q?(Sylvain=20Corr=C3=A9=20<sylvain=20dot=20corre=20at=20wanadoo.f?=
 =?UTF-8?q?r>)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Originally committed as revision 1694 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 ffmpeg.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 5925d834674..11040138d26 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -335,11 +335,21 @@ static void do_audio_out(AVFormatContext *s,
                          unsigned char *buf, int size)
 {
     uint8_t *buftmp;
-    uint8_t audio_buf[2*MAX_AUDIO_PACKET_SIZE]; /* XXX: allocate it */
-    uint8_t audio_out[4*MAX_AUDIO_PACKET_SIZE]; /* XXX: allocate it - yep really WMA */
+    static uint8_t *audio_buf = NULL;
+    static uint8_t *audio_out = NULL;
+
     int size_out, frame_bytes, ret;
     AVCodecContext *enc;
 
+    /* SC: dynamic allocation of buffers */
+    if (!audio_buf)
+        audio_buf = av_malloc(2*MAX_AUDIO_PACKET_SIZE);
+    if (!audio_out)
+        audio_out = av_malloc(4*MAX_AUDIO_PACKET_SIZE);
+    if (!audio_buf || !audio_out)
+        return;               /* Should signal an error ! */
+
+    
     enc = &ost->st->codec;
 
     if (ost->audio_resample) {
-- 
GitLab