diff options
author | Andriy Gelman <andriy.gelman@gmail.com> | 2020-08-02 14:31:22 -0400 |
---|---|---|
committer | Andriy Gelman <andriy.gelman@gmail.com> | 2020-08-02 14:31:22 -0400 |
commit | 7c32e9cf93b712f8463573a59ed4e98fd10fa013 (patch) | |
tree | 988cc874d44007f795db21eab5eafc7ba2d5f59c /libavcodec/v4l2_m2m.c | |
parent | 533d6030ca3e64c87aeb9d04917b716aa8341385 (diff) | |
download | ffmpeg-7c32e9cf93b712f8463573a59ed4e98fd10fa013.tar.gz |
avcodec/v4l2_m2m: adapt to call close() on init fail
This fixes several mem leaks when init of encoder/decoder failed.
Fixes ticket #8285
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Diffstat (limited to 'libavcodec/v4l2_m2m.c')
-rw-r--r-- | libavcodec/v4l2_m2m.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c index d8d872ea09..944c1a2823 100644 --- a/libavcodec/v4l2_m2m.c +++ b/libavcodec/v4l2_m2m.c @@ -330,6 +330,7 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context) close(s->fd); av_frame_free(&s->frame); + av_packet_unref(&s->buf_pkt); av_free(s); } @@ -339,6 +340,10 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv) V4L2m2mContext *s = priv->context; int ret; + if (!s) + return 0; + + if (s->fd >= 0) { ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); if (ret) av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name); @@ -346,6 +351,7 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv) ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); if (ret) av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name); + } ff_v4l2_context_release(&s->output); |