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

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


vlc/vlc-3.0 | branch: master | Alexandre Janniaux <alexandre.janniaux at gmail.com> | Thu Dec  6 21:36:07 2018 +0100| [bedc72800f1a5fd2a4d1bb59417bb6605757a8de] | 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>
(cherry picked from commit f69475d477e6c597a47b8bc55ee61fdf2ec23f02)

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

 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 c587e2b243..670d03d7ef 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -346,12 +346,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