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

Alexandre Janniaux git at videolan.org
Thu Dec 6 21:52:08 CET 2018


vlc | branch: master | Alexandre Janniaux <alexandre.janniaux at gmail.com> | Thu Dec  6 21:36:07 2018 +0100| [f69475d477e6c597a47b8bc55ee61fdf2ec23f02] | committer: Tristan Matthews

avcodec/encoder: fix leak in case of codec opening failure

If the required codec is invalid or doesn't match the required codec id,
we must release the string obtained from var_GetString.

Signed-off-by: Tristan Matthews <tmatth at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f69475d477e6c597a47b8bc55ee61fdf2ec23f02
---

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



More information about the vlc-commits mailing list