diff mbox series

[FFmpeg-devel] fftools/ffplay: fix possible memory leak in decoder

Message ID 20200305223600.26918-1-cus@passwd.hu
State Accepted
Headers show
Series [FFmpeg-devel] fftools/ffplay: fix possible memory leak in decoder
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Marton Balint March 5, 2020, 10:36 p.m. UTC
Fixes ticket #8549.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 fftools/ffplay.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Marton Balint March 8, 2020, 6:34 p.m. UTC | #1
On Thu, 5 Mar 2020, Marton Balint wrote:

> Fixes ticket #8549.

Applied.

Regards,
Marton

>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> fftools/ffplay.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index fee0619f7c..f6511e4afd 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -644,7 +644,10 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
>                 if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0)
>                     return -1;
>             }
> -        } while (d->queue->serial != d->pkt_serial);
> +            if (d->queue->serial == d->pkt_serial)
> +                break;
> +            av_packet_unref(&pkt);
> +        } while (1);
>
>         if (pkt.data == flush_pkt.data) {
>             avcodec_flush_buffers(d->avctx);
> -- 
> 2.16.4
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index fee0619f7c..f6511e4afd 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -644,7 +644,10 @@  static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
                 if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0)
                     return -1;
             }
-        } while (d->queue->serial != d->pkt_serial);
+            if (d->queue->serial == d->pkt_serial)
+                break;
+            av_packet_unref(&pkt);
+        } while (1);
 
         if (pkt.data == flush_pkt.data) {
             avcodec_flush_buffers(d->avctx);