[1/4] libopenh264dec: Fix cleanup if the init failed early

Message ID 1468525196-59168-1-git-send-email-martin@martin.st
State Committed
Commit d0b1e6049b06eeeeca146ece4d2f199c5dba1565
Headers show

Commit Message

Martin Storsjö July 14, 2016, 7:39 p.m.
---
 libavcodec/libopenh264dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luca Barbato July 14, 2016, 7:52 p.m. | #1
On 14/07/16 21:39, Martin Storsjö wrote:
> ---
>  libavcodec/libopenh264dec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
> index cdbea7b..a105fa5 100644
> --- a/libavcodec/libopenh264dec.c
> +++ b/libavcodec/libopenh264dec.c
> @@ -48,7 +48,7 @@ static av_cold int svc_decode_close(AVCodecContext *avctx)
>      if (s->decoder)
>          WelsDestroyDecoder(s->decoder);
>  
> -    while (av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
> +    while (s->packet_fifo && av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
>          av_fifo_generic_read(s->packet_fifo, &pkt, sizeof(pkt), NULL);
>          av_packet_unref(&pkt);
>      }
> 

Ok.

Patch

diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
index cdbea7b..a105fa5 100644
--- a/libavcodec/libopenh264dec.c
+++ b/libavcodec/libopenh264dec.c
@@ -48,7 +48,7 @@  static av_cold int svc_decode_close(AVCodecContext *avctx)
     if (s->decoder)
         WelsDestroyDecoder(s->decoder);
 
-    while (av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
+    while (s->packet_fifo && av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
         av_fifo_generic_read(s->packet_fifo, &pkt, sizeof(pkt), NULL);
         av_packet_unref(&pkt);
     }