[FFmpeg-cvslog] hevcdec: do not set decoder-global SPS prematurely

Anton Khirnov git at videolan.org
Wed Apr 26 18:28:51 EEST 2017


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Dec 18 22:06:32 2016 +0100| [373fd76b4dbd9aa03ed28e502f33f2ca8c1ce19a] | committer: Anton Khirnov

hevcdec: do not set decoder-global SPS prematurely

It should only be set after the decoder state has been fully initialized
for using that SPS.
Fixes possible invalid reads on get_format() failure.

CC: libav-stable at libav.org

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=373fd76b4dbd9aa03ed28e502f33f2ca8c1ce19a
---

 libavcodec/hevcdec.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 27fd6832ab..147243e3fe 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -479,17 +479,16 @@ static int hls_slice_header(HEVCContext *s)
     s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data;
 
     if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) {
+        const HEVCSPS *sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data;
         enum AVPixelFormat pix_fmt;
 
-        s->ps.sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data;
-
         ff_hevc_clear_refs(s);
 
-        pix_fmt = get_format(s, s->ps.sps);
+        pix_fmt = get_format(s, sps);
         if (pix_fmt < 0)
             return pix_fmt;
 
-        ret = set_sps(s, s->ps.sps, pix_fmt);
+        ret = set_sps(s, sps, pix_fmt);
         if (ret < 0)
             return ret;
 



More information about the ffmpeg-cvslog mailing list