aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-12-08 14:48:36 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-12-08 14:48:36 +0000
commitb8919a30923d4be9033b925b509e54b0ef6ad98c (patch)
treebddcddbc818b31dfa71bc2ce410134475c7230da
parent15bfe412b773473e242e6630f725d5a3f935b5d7 (diff)
downloadffmpeg-b8919a30923d4be9033b925b509e54b0ef6ad98c.tar.gz
10l bug, use av_fast_malloc() instead if av_malloc() for allocating audio
buffers. This and the previous revision fix a heap overflow. Originally committed as revision 20769 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--ffmpeg.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 88e5718115..01b51e817b 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -219,6 +219,7 @@ static int64_t timer_start;
static uint8_t *audio_buf;
static uint8_t *audio_out;
+unsigned int allocated_audio_out_size, allocated_audio_buf_size;
static short *samples;
@@ -449,6 +450,7 @@ static int av_exit(int ret)
av_free(sws_opts);
av_free(audio_buf);
av_free(audio_out);
+ allocated_audio_buf_size= allocated_audio_out_size= 0;
av_free(samples);
if (received_sigterm) {
@@ -579,11 +581,8 @@ static void do_audio_out(AVFormatContext *s,
av_exit(1);
}
- /* SC: dynamic allocation of buffers */
- if (!audio_buf)
- audio_buf = av_malloc(audio_buf_size);
- if (!audio_out)
- audio_out = av_malloc(audio_out_size);
+ av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size);
+ av_fast_malloc(&audio_out, &allocated_audio_out_size, audio_out_size);
if (!audio_buf || !audio_out)
return; /* Should signal an error ! */