[FFmpeg-devel] [PATCH] diracdec: check if reference could not be allocated

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Tue May 5 23:51:48 CEST 2015


s->ref_pics[i] is later used as ref argument of interpolate_refplane,
where it is dereferenced.

If it is NULL, it causes a segmentation fault.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavcodec/diracdec.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 98f2ea9..2057014 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -1749,6 +1749,12 @@ static int dirac_decode_picture_header(DiracContext *s)
                     get_buffer_with_edge(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
                     break;
                 }
+
+        if (!s->ref_pics[i]) {
+            av_log(s->avctx, AV_LOG_ERROR, "Reference could not be allocated\n");
+            return -1;
+        }
+
     }
 
     /* retire the reference frames that are not used anymore */
-- 
2.1.4


More information about the ffmpeg-devel mailing list