]> git.sesse.net Git - ffmpeg/commitdiff
lavc/psymodel: check for av_malloc failure
authorGanesh Ajjanagadde <gajjanag@gmail.com>
Thu, 3 Mar 2016 01:14:08 +0000 (20:14 -0500)
committerGanesh Ajjanagadde <gajjanag@gmail.com>
Wed, 23 Mar 2016 15:22:22 +0000 (08:22 -0700)
No idea why in commit 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec the
checks were removed; this can lead to NULL pointer dereferences. This
effectively reverts that portion of the commit.

Reviewed-by: Benoit Fouet <benoit.fouet@free.fr>
Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag@gmail.com>
libavcodec/psymodel.c

index 6274a49ea92f25f830b876edb9fc9346a08cf4fa..2b5f111fbe636ce6e7eba0efef0e99c72ee588d4 100644 (file)
@@ -120,7 +120,12 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av
                                                  FF_FILTER_MODE_LOWPASS, FILT_ORDER,
                                                  cutoff_coeff, 0.0, 0.0);
         if (ctx->fcoeffs) {
-            ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels);
+            ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), avctx->channels);
+            if (!ctx->fstate) {
+                av_free(ctx->fcoeffs);
+                av_free(ctx);
+                return NULL;
+            }
             for (i = 0; i < avctx->channels; i++)
                 ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER);
         }