Fix v4l2 AVPacket memory leak on error

Unref v4l2 AVPacket even if writing failed.
This commit is contained in:
Romain Vimont 2021-04-26 18:05:11 +02:00
parent 1cde68a1fa
commit 84f17fdeab

View file

@ -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;