[vlc-commits] ffmpeg: only free the options if there were any
Steve Lhomme
git at videolan.org
Fri Aug 5 18:11:50 CEST 2016
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Fri Aug 5 11:28:01 2016 +0200| [4919758a95cf8dd6a7a3cbaa4603e54943aec90a] | committer: Jean-Baptiste Kempf
ffmpeg: only free the options if there were any
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4919758a95cf8dd6a7a3cbaa4603e54943aec90a
---
modules/access/avio.c | 4 ++--
modules/codec/avcodec/avcodec.c | 5 +++--
modules/codec/avcodec/encoder.c | 5 +++--
modules/codec/avcodec/subtitle.c | 5 +++--
modules/demux/avformat/demux.c | 4 ++--
modules/demux/avformat/mux.c | 5 +++--
6 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/modules/access/avio.c b/modules/access/avio.c
index 3a3b478..2181eaf 100644
--- a/modules/access/avio.c
+++ b/modules/access/avio.c
@@ -158,7 +158,7 @@ int OpenAvio(vlc_object_t *object)
};
AVDictionary *options = NULL;
char *psz_opts = var_InheritString(access, "avio-options");
- if (psz_opts && *psz_opts) {
+ if (psz_opts) {
options = vlc_av_get_options(psz_opts);
free(psz_opts);
}
@@ -238,7 +238,7 @@ int OutOpenAvio(vlc_object_t *object)
#else
AVDictionary *options = NULL;
char *psz_opts = var_InheritString(access, "sout-avio-options");
- if (psz_opts && *psz_opts) {
+ if (psz_opts) {
options = vlc_av_get_options(psz_opts);
free(psz_opts);
}
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 5402f69..d471077 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -357,9 +357,10 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
AVDictionary *options = NULL;
int ret;
- if (psz_opts && *psz_opts)
+ if (psz_opts) {
options = vlc_av_get_options(psz_opts);
- free(psz_opts);
+ free(psz_opts);
+ }
vlc_avcodec_lock();
ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, options ? &options : NULL );
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index e2f0546..0f37683 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -892,9 +892,10 @@ int OpenEncoder( vlc_object_t *p_this )
int ret;
char *psz_opts = var_InheritString(p_enc, ENC_CFG_PREFIX "options");
AVDictionary *options = NULL;
- if (psz_opts && *psz_opts)
+ if (psz_opts) {
options = vlc_av_get_options(psz_opts);
- free(psz_opts);
+ free(psz_opts);
+ }
vlc_avcodec_lock();
ret = avcodec_open2( p_context, p_codec, options ? &options : NULL );
diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index de4d3e4..26d8754 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -89,9 +89,10 @@ int InitSubtitleDec(decoder_t *dec, AVCodecContext *context,
int ret;
char *psz_opts = var_InheritString(dec, "avcodec-options");
AVDictionary *options = NULL;
- if (psz_opts && *psz_opts)
+ if (psz_opts) {
options = vlc_av_get_options(psz_opts);
- free(psz_opts);
+ free(psz_opts);
+ }
vlc_avcodec_lock();
ret = avcodec_open2(context, codec, options ? &options : NULL);
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 210830e..f962862 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -336,13 +336,13 @@ int OpenDemux( vlc_object_t *p_this )
unsigned int nb_streams = p_sys->ic->nb_streams;
for (unsigned i = 1; i < nb_streams; i++)
options[i] = NULL;
- if (psz_opts && *psz_opts) {
+ if (psz_opts) {
options[0] = vlc_av_get_options(psz_opts);
for (unsigned i = 1; i < nb_streams; i++) {
av_dict_copy(&options[i], options[0], 0);
}
+ free(psz_opts);
}
- free(psz_opts);
vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */
error = avformat_find_stream_info( p_sys->ic, options );
/* FIXME: what if nb_streams change after that call? */
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 75e38f9..b5ff838 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -378,9 +378,10 @@ static int Mux( sout_mux_t *p_mux )
char *psz_opts = var_GetNonEmptyString( p_mux, "sout-avformat-options" );
AVDictionary *options = NULL;
- if (psz_opts && *psz_opts)
+ if (psz_opts) {
options = vlc_av_get_options(psz_opts);
- free(psz_opts);
+ free(psz_opts);
+ }
error = avformat_write_header( p_sys->oc, options ? &options : NULL);
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(options, "", t, AV_DICT_IGNORE_SUFFIX))) {
More information about the vlc-commits
mailing list