diff mbox

[FFmpeg-devel] libavcodec/v4l2_m2m_enc:free v4l2 encode session properly when initialiZzation fails Fix ticket 8285 bug

Message ID BN6PR22MB03374B6C5BF656E3CB01FB19FE690@BN6PR22MB0337.namprd22.prod.outlook.com
State New
Headers show

Commit Message

Colin NG Oct. 21, 2019, 11:01 p.m. UTC
---
 libavcodec/v4l2_m2m_enc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andriy Gelman Nov. 3, 2019, 2:55 a.m. UTC | #1
On Mon, 21. Oct 23:01, Colin NG wrote:
> ---
>  libavcodec/v4l2_m2m_enc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index 474e6bef89..17fc3d30cf 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -312,6 +312,7 @@ static av_cold int v4l2_encode_init(AVCodecContext *avctx)
>      ret = ff_v4l2_m2m_codec_init(priv);
>      if (ret) {
>          av_log(avctx, AV_LOG_ERROR, "can't configure encoder\n");

> +        ff_v4l2_m2m_codec_end(priv);

Is it better to add .caps_internal = FF_CODEC_CAP_INIT_CLEANUP instead ? 
This will avoid the same mem leak if v4l2_prepare_encoder() fails below.

Also, fix your commit title/message. 

Thanks,
diff mbox

Patch

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 474e6bef89..17fc3d30cf 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -312,6 +312,7 @@  static av_cold int v4l2_encode_init(AVCodecContext *avctx)
     ret = ff_v4l2_m2m_codec_init(priv);
     if (ret) {
         av_log(avctx, AV_LOG_ERROR, "can't configure encoder\n");
+        ff_v4l2_m2m_codec_end(priv);
         return ret;
     }
     s->avctx = avctx;