]> git.sesse.net Git - ffmpeg/commit
avcodec/v4l2_m2m_dec: remove redundant packet and fix double free
authorAndriy Gelman <andriy.gelman@gmail.com>
Thu, 16 Jul 2020 14:52:12 +0000 (10:52 -0400)
committerAndriy Gelman <andriy.gelman@gmail.com>
Thu, 16 Jul 2020 15:25:23 +0000 (11:25 -0400)
commita9fecb8ea181d285a3218e27c97e5857925731d8
treeb80345b18527b2a902e0488080a7e173a1e8ba39
parent660386813d34c1bdde685a3b8e0628a882d8cb22
avcodec/v4l2_m2m_dec: remove redundant packet and fix double free

v4l2_receive_frame() uses two packets s->buf_pkt and avpkt. If avpkt
cannot be enqueued, the packet is buffered in s->buf_pkt and enqueued in
the next call. Currently the ownership transfer between the two packets
is not properly handled. A double free occurs if
ff_v4l2_context_enqueue_packet() returns EAGAIN and v4l2_try_start
returns EINVAL.

In fact, having two AVPackets is not needed and everything can be
handled by s->buf_pkt.

This commit removes the local avpkt from v4l2_receive_frame(), meaning
that the ownership transfer doesn't need to be handled and the double
free is fixed.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
libavcodec/v4l2_m2m_dec.c