summaryrefslogtreecommitdiff
path: root/cmdutils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-12-19 04:57:25 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-12-19 04:57:25 +0100
commit988d27b8029d9b4ccb13e792004cc8375b835eac (patch)
tree8931c74a18dcf3876f6db7569a7404b64ed5abab /cmdutils.c
parent76a8127a452f9e149a876c5fa6d6f0634e3b5b1e (diff)
parentb1306823d0b3ae998c8e10ad832004eb13bdd93e (diff)
downloadffmpeg-988d27b8029d9b4ccb13e792004cc8375b835eac.tar.gz
Merge commit 'b1306823d0b3ae998c8e10ad832004eb13bdd93e'
* commit 'b1306823d0b3ae998c8e10ad832004eb13bdd93e': check memory errors from av_strdup() Conflicts: avprobe.c libavformat/matroskaenc.c libavutil/opt.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'cmdutils.c')
-rw-r--r--cmdutils.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 8b6edfc9c5..2b4ab9e4d8 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -290,10 +290,14 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
if (po->flags & OPT_SPEC) {
SpecifierOpt **so = dst;
char *p = strchr(opt, ':');
+ char *str;
dstcount = (int *)(so + 1);
*so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1);
- (*so)[*dstcount - 1].specifier = av_strdup(p ? p + 1 : "");
+ str = av_strdup(p ? p + 1 : "");
+ if (!str)
+ return AVERROR(ENOMEM);
+ (*so)[*dstcount - 1].specifier = str;
dst = &(*so)[*dstcount - 1].u;
}
@@ -301,6 +305,8 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
char *str;
str = av_strdup(arg);
av_freep(dst);
+ if (!str)
+ return AVERROR(ENOMEM);
*(char **)dst = str;
} else if (po->flags & OPT_BOOL || po->flags & OPT_INT) {
*(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
@@ -1816,6 +1822,8 @@ int show_help(void *optctx, const char *opt, const char *arg)
av_log_set_callback(log_callback_help);
topic = av_strdup(arg ? arg : "");
+ if (!topic)
+ return AVERROR(ENOMEM);
par = strchr(topic, '=');
if (par)
*par++ = 0;