Commit 285b706b authored by Janne Grunau's avatar Janne Grunau
Browse files

avfilter: fix graphparser memleaks on error paths

Fixes CID700635, CID700636 and CID732274.
parent 587874ef
...@@ -238,10 +238,11 @@ static int link_filter_inouts(AVFilterContext *filt_ctx, ...@@ -238,10 +238,11 @@ static int link_filter_inouts(AVFilterContext *filt_ctx,
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if (p->filter_ctx) { if (p->filter_ctx) {
if ((ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx)) < 0) ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx);
return ret;
av_free(p->name); av_free(p->name);
av_free(p); av_free(p);
if (ret < 0)
return ret;
} else { } else {
p->filter_ctx = filt_ctx; p->filter_ctx = filt_ctx;
p->pad_idx = pad; p->pad_idx = pad;
...@@ -289,8 +290,10 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, ...@@ -289,8 +290,10 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs,
av_free(name); av_free(name);
} else { } else {
/* Not in the list, so add it as an input */ /* Not in the list, so add it as an input */
if (!(match = av_mallocz(sizeof(AVFilterInOut)))) if (!(match = av_mallocz(sizeof(AVFilterInOut)))) {
av_free(name);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
match->name = name; match->name = name;
match->pad_idx = pad; match->pad_idx = pad;
} }
...@@ -318,24 +321,27 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, ...@@ -318,24 +321,27 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs,
AVFilterInOut *match; AVFilterInOut *match;
AVFilterInOut *input = *curr_inputs; AVFilterInOut *input = *curr_inputs;
if (!name)
return AVERROR(EINVAL);
if (!input) { if (!input) {
av_log(log_ctx, AV_LOG_ERROR, av_log(log_ctx, AV_LOG_ERROR,
"No output pad can be associated to link label '%s'.\n", "No output pad can be associated to link label '%s'.\n", name);
name); av_free(name);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
*curr_inputs = (*curr_inputs)->next; *curr_inputs = (*curr_inputs)->next;
if (!name)
return AVERROR(EINVAL);
/* First check if the label is not in the open_inputs list */ /* First check if the label is not in the open_inputs list */
match = extract_inout(name, open_inputs); match = extract_inout(name, open_inputs);
if (match) { if (match) {
if ((ret = link_filter(input->filter_ctx, input->pad_idx, if ((ret = link_filter(input->filter_ctx, input->pad_idx,
match->filter_ctx, match->pad_idx, log_ctx)) < 0) match->filter_ctx, match->pad_idx, log_ctx)) < 0) {
av_free(name);
return ret; return ret;
}
av_free(match->name); av_free(match->name);
av_free(name); av_free(name);
av_free(match); av_free(match);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment