diff mbox

[FFmpeg-devel] Fix null dereferences in the qsv decoder

Message ID 1469804444-32575-1-git-send-email-ykhodo@gmail.com
State Accepted
Commit f0adb99d068e659178c00271a46cd469dfc01a6e
Headers show

Commit Message

Yuli Khodorkovskiy July 29, 2016, 3 p.m. UTC
This patch fixes the h264_qsv decoder issues mentioned
in https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2962.

The patch may be tested by specifying h264_qsv as the decoder to ffplay
for an h264 encoded file.

	ffplay -vcodec h264_qsv foo.mts

Signed-off-by: Yuli Khodorkovskiy <ykhodo@gmail.com>
---
 libavcodec/qsvdec.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Ivan Uskov Aug. 7, 2016, 3:45 p.m. UTC | #1
Hello Yuli,

Friday, July 29, 2016, 6:00:44 PM, you wrote:

> This patch fixes the h264_qsv decoder issues mentioned
> in https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2962.

> The patch may be tested by specifying h264_qsv as the decoder to ffplay
> for an h264 encoded file.

>         ffplay -vcodec h264_qsv foo.mts

> Signed-off-by: Yuli Khodorkovskiy <ykhodo@gmail.com>
> ---
>  libavcodec/qsvdec.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 9125700..98585e3 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -555,16 +555,18 @@ void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q)
>      }
>  
>      /* Reset output surfaces */
> -    av_fifo_reset(q->async_fifo);
+    if (q->>async_fifo)
> +        av_fifo_reset(q->async_fifo);
>  
>      /* Reset input packets fifo */
> -    while (av_fifo_size(q->pkt_fifo)) {
+    while (q->>pkt_fifo && av_fifo_size(q->pkt_fifo)) {
>          av_fifo_generic_read(q->pkt_fifo, &pkt, sizeof(pkt), NULL);
>          av_packet_unref(&pkt);
>      }
>  
>      /* Reset input bitstream fifo */
> -    av_fifo_reset(q->input_fifo);
+    if (q->>input_fifo)
> +        av_fifo_reset(q->input_fifo);
>  }
>  
>  int ff_qsv_decode_close(QSVContext *q)
Really, makes sense.
Looks good for me.
Michael Niedermayer Aug. 7, 2016, 5:08 p.m. UTC | #2
On Sun, Aug 07, 2016 at 06:45:18PM +0300, Ivan Uskov wrote:
> 
> Hello Yuli,
> 
> Friday, July 29, 2016, 6:00:44 PM, you wrote:
> 
> > This patch fixes the h264_qsv decoder issues mentioned
> > in https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2962.
> 
> > The patch may be tested by specifying h264_qsv as the decoder to ffplay
> > for an h264 encoded file.
> 
> >         ffplay -vcodec h264_qsv foo.mts
> 
> > Signed-off-by: Yuli Khodorkovskiy <ykhodo@gmail.com>
> > ---
> >  libavcodec/qsvdec.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index 9125700..98585e3 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -555,16 +555,18 @@ void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q)
> >      }
> >  
> >      /* Reset output surfaces */
> > -    av_fifo_reset(q->async_fifo);
> +    if (q->>async_fifo)
> > +        av_fifo_reset(q->async_fifo);
> >  
> >      /* Reset input packets fifo */
> > -    while (av_fifo_size(q->pkt_fifo)) {
> +    while (q->>pkt_fifo && av_fifo_size(q->pkt_fifo)) {
> >          av_fifo_generic_read(q->pkt_fifo, &pkt, sizeof(pkt), NULL);
> >          av_packet_unref(&pkt);
> >      }
> >  
> >      /* Reset input bitstream fifo */
> > -    av_fifo_reset(q->input_fifo);
> +    if (q->>input_fifo)
> > +        av_fifo_reset(q->input_fifo);
> >  }
> >  
> >  int ff_qsv_decode_close(QSVContext *q)
> Really, makes sense.
> Looks good for me.

applied

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 9125700..98585e3 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -555,16 +555,18 @@  void ff_qsv_decode_reset(AVCodecContext *avctx, QSVContext *q)
     }
 
     /* Reset output surfaces */
-    av_fifo_reset(q->async_fifo);
+    if (q->async_fifo)
+        av_fifo_reset(q->async_fifo);
 
     /* Reset input packets fifo */
-    while (av_fifo_size(q->pkt_fifo)) {
+    while (q->pkt_fifo && av_fifo_size(q->pkt_fifo)) {
         av_fifo_generic_read(q->pkt_fifo, &pkt, sizeof(pkt), NULL);
         av_packet_unref(&pkt);
     }
 
     /* Reset input bitstream fifo */
-    av_fifo_reset(q->input_fifo);
+    if (q->input_fifo)
+        av_fifo_reset(q->input_fifo);
 }
 
 int ff_qsv_decode_close(QSVContext *q)