aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-14 02:59:51 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-27 07:20:57 +0100
commit5000bae8305950f0412df240fb17f1f48c8f7590 (patch)
tree374b9f215668b3e014553d7b07ef599fef5f481f
parent7cfa8e1910d708d81b808dfe54c76e7b39523253 (diff)
downloadffmpeg-5000bae8305950f0412df240fb17f1f48c8f7590.tar.gz
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@gmail.com> (cherry picked from commit ae36fad624307dcd1bbe0c954a017293a1ce34d3)
-rw-r--r--libavcodec/ac3enc_template.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index be659872f7..5a67d8d51f 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -43,7 +43,7 @@ int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s)
FF_ALLOC_OR_GOTO(s->avctx, s->windowed_samples, AC3_WINDOW_SIZE *
sizeof(*s->windowed_samples), alloc_fail);
- FF_ALLOC_ARRAY_OR_GOTO(s->avctx, s->planar_samples, s->channels, sizeof(*s->planar_samples),
+ FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->planar_samples, s->channels, sizeof(*s->planar_samples),
alloc_fail);
for (ch = 0; ch < s->channels; ch++) {
FF_ALLOCZ_OR_GOTO(s->avctx, s->planar_samples[ch],