From 45286a625c6ced1f5c4c842244cbb4509429abba Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 18 Dec 2016 11:29:25 +0100 Subject: h264dec: make sure to only end a field if it has been started Calling ff_h264_field_end() when the per-field state is not properly initialized leads to all kinds of undefined behaviour. CC: libav-stable@libav.org Bug-Id: 977 978 992 --- libavcodec/h264_slice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libavcodec/h264_slice.c') diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 1b91088f52..db7628cf97 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1884,9 +1884,8 @@ int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal) sl = h->slice_ctx; } - if (h->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) { + if (h->field_started) ff_h264_field_end(h, sl, 1); - } h->current_slice = 0; if (!h->first_field) { @@ -1902,6 +1901,7 @@ int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal) ret = h264_field_start(h, sl, nal); if (ret < 0) return ret; + h->field_started = 1; } } -- cgit v1.2.3