Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2011-02-05 05:29:46 +0300
committerMichael Niedermayer <michaelni@gmx.at>2011-02-06 22:31:45 +0300
commit3f171f5aec6a7e0e0f8a84520923824191a48f36 (patch)
treecbca2f7fd0514410ad2852cef7d8875cf4422f11 /cmdutils.c
parentba3517aa6f573d280d80866e776885be7f01de77 (diff)
cmdutils: fix codec-specific options from preset
Using a preset file caused the address of a stack variable to be stored in opt_names/values. This change causes the strings to be dup'd then freed in uninit_opts. Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com> (cherry picked from commit 60ff9de6ffa740e0df8c2a019c72e2d332b9788d)
Diffstat (limited to 'cmdutils.c')
-rw-r--r--cmdutils.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 99e4c38af1..c68f37fe20 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -78,6 +78,14 @@ void uninit_opts(void)
#if CONFIG_SWSCALE
av_freep(&sws_opts);
#endif
+ for (i = 0; i < opt_name_count; i++) {
+ //opt_values are only stored for codec-specific options in which case
+ //both the name and value are dup'd
+ if (opt_values[i]) {
+ av_freep(&opt_names[i]);
+ av_freep(&opt_values[i]);
+ }
+ }
av_freep(&opt_names);
av_freep(&opt_values);
}
@@ -270,9 +278,9 @@ int opt_default(const char *opt, const char *arg){
//FIXME we should always use avcodec_opts, ... for storing options so there will not be any need to keep track of what i set over this
opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1));
- opt_values[opt_name_count]= o ? NULL : arg;
+ opt_values[opt_name_count]= o ? NULL : av_strdup(arg);
opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
- opt_names[opt_name_count++]= o ? o->name : opt;
+ opt_names[opt_name_count++]= o ? o->name : av_strdup(opt);
if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug))
av_log_set_level(AV_LOG_DEBUG);