diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c
index 1243f43c18eeb198c99a5f993dc8c2d81f87e74b..97bd801aa7e1fdd6027d1bd98c8f820503ab937c 100644
--- a/libavformat/audiointerleave.c
+++ b/libavformat/audiointerleave.c
@@ -67,7 +67,8 @@ int ff_audio_interleave_init(AVFormatContext *s,
             aic->time_base = time_base;
 
             aic->fifo_size = 100* *aic->samples;
-            aic->fifo= av_fifo_alloc_array(100, *aic->samples);
+            if (!(aic->fifo= av_fifo_alloc_array(100, *aic->samples)))
+                return AVERROR(ENOMEM);
         }
     }