]> git.sesse.net Git - ffmpeg/commitdiff
hevcdec: do not set decoder-global SPS prematurely
authorAnton Khirnov <anton@khirnov.net>
Sun, 18 Dec 2016 21:06:32 +0000 (22:06 +0100)
committerAnton Khirnov <anton@khirnov.net>
Mon, 19 Dec 2016 07:07:15 +0000 (08:07 +0100)
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@libav.org
libavcodec/hevcdec.c

index 27fd6832ab2e3c8f4ac3aa3cafe96b2e6ca063d0..147243e3fe52778069c5e7d0b87ad03972c840f1 100644 (file)
@@ -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;