diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2014-12-17 16:53:45 +0300 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2014-12-19 01:27:14 +0300 |
commit | b1306823d0b3ae998c8e10ad832004eb13bdd93e (patch) | |
tree | 2e7642dc896d7f19682f50b913ab5b5be57b83ac /cmdutils.c | |
parent | 9745f19ffc9031ce480e43d7cf1053b58100d70f (diff) |
check memory errors from av_strdup()
Diffstat (limited to 'cmdutils.c')
-rw-r--r-- | cmdutils.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cmdutils.c b/cmdutils.c index 19589cea5b..f074dd0861 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -261,10 +261,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; } @@ -272,6 +276,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); @@ -1350,6 +1356,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; |