[vlc-devel] [PATCH] avcodec/encoder: fix leak in case of codec opening failure

Alexandre Janniaux alexandre.janniaux at gmail.com
Thu Dec 6 21:36:07 CET 2018


If the required codec is invalid or doesn't match the required codec id,
we must release the string obtained from var_GetString.
---
 modules/codec/avcodec/encoder.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 201049cf1f..c845723a1d 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -344,12 +344,14 @@ int InitVideoEnc( vlc_object_t *p_this )
         if( !p_codec )
         {
             msg_Err( p_this, "Encoder `%s' not found", psz_encoder );
+            free( psz_encoder );
             return VLC_EGENERIC;
         }
         else if( p_codec->id != i_codec_id )
         {
             msg_Err( p_this, "Encoder `%s' can't handle %4.4s",
                     psz_encoder, (char*)&p_enc->fmt_out.i_codec );
+            free( psz_encoder );
             return VLC_EGENERIC;
         }
     }
-- 
2.19.2



More information about the vlc-devel mailing list