[FFmpeg-cvslog] avcodec/ac3enc_template: Don't free uninitialized pointers on error

Andreas Rheinhardt git at videolan.org
Fri Sep 18 04:10:40 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Mon Sep 14 02:59:51 2020 +0200| [ae36fad624307dcd1bbe0c954a017293a1ce34d3] | committer: Andreas Rheinhardt

avcodec/ac3enc_template: Don't free uninitialized pointers on error

The ac3 encoders (fixed- and floating-point AC-3 as well as the EAC-3
encoder) all allocate an array whose elements are pointers to other
buffers. The array is not zeroed initially so that if an allocation of
one of the subbuffers fails, the other pointers are uninitialized.
This causes problems when cleaning, so zero the array initially.

(Only the fixed-point AC-3 encoder was affected by this, because
the other two don't clean up at all in case of errors during init.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavcodec/ac3enc_template.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 985b35e5b6..b85fe51ef5 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -42,7 +42,7 @@ int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s)
     int ch;
 
     if (!FF_ALLOC_TYPED_ARRAY(s->windowed_samples, AC3_WINDOW_SIZE) ||
-        !FF_ALLOC_TYPED_ARRAY(s->planar_samples,   s->channels))
+        !FF_ALLOCZ_TYPED_ARRAY(s->planar_samples,  s->channels))
         return AVERROR(ENOMEM);
 
     for (ch = 0; ch < s->channels; ch++) {



More information about the ffmpeg-cvslog mailing list