Skip to content

Display and control your Android device

Fix v4l2 AVPacket memory leak on error

Romain Vimont84f17fdeab51
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;