From 84f17fdeab518cbe9f9c1a5fdf7dc50981c01806 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 26 Apr 2021 18:05:11 +0200 Subject: [PATCH] Fix v4l2 AVPacket memory leak on error Unref v4l2 AVPacket even if writing failed. --- app/src/v4l2_sink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/v4l2_sink.c b/app/src/v4l2_sink.c index 9b4a9c85..fd0bda12 100644 --- a/app/src/v4l2_sink.c +++ b/app/src/v4l2_sink.c @@ -92,11 +92,11 @@ encode_and_write_frame(struct sc_v4l2_sink *vs, const AVFrame *frame) { // A packet was received bool ok = write_packet(vs, packet); + av_packet_unref(packet); if (!ok) { LOGW("Could not send packet to v4l2 sink"); return false; } - av_packet_unref(packet); } else if (ret != AVERROR(EAGAIN)) { LOGE("Could not receive v4l2 video packet: %d", ret); return false;