Fixes CID700635, CID700636 and CID732274.
Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all
Unified · Split
| @@ -238,10 +238,11 @@ static int link_filter_inouts(AVFilterContext *filt_ctx, · 237 unmodified lines | ||
| 238 | 238 | return AVERROR(ENOMEM); |
| 239 | 239 | |
| 240 | 240 | if (p->filter_ctx) { |
| 241 | − if ((ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx)) < 0) | |
| 242 | − return ret; | |
| 241 | + ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx); | |
| 243 | 242 | av_free(p->name); |
| 244 | 243 | av_free(p); |
| 244 | + if (ret < 0) | |
| 245 | + return ret; | |
| 245 | 246 | } else { |
| 246 | 247 | p->filter_ctx = filt_ctx; |
| 247 | 248 | p->pad_idx = pad; |
| @@ -289,8 +290,10 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, · 41 unmodified lines | ||
| 289 | 290 | av_free(name); |
| 290 | 291 | } else { |
| 291 | 292 | /* Not in the list, so add it as an input */ |
| 292 | − if (!(match = av_mallocz(sizeof(AVFilterInOut)))) | |
| 293 | + if (!(match = av_mallocz(sizeof(AVFilterInOut)))) { | |
| 294 | + av_free(name); | |
| 293 | 295 | return AVERROR(ENOMEM); |
| 296 | + } | |
| 294 | 297 | match->name = name; |
| 295 | 298 | match->pad_idx = pad; |
| 296 | 299 | } |
| @@ -318,24 +321,27 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, · 21 unmodified lines | ||
| 318 | 321 | AVFilterInOut *match; |
| 319 | 322 | |
| 320 | 323 | AVFilterInOut *input = *curr_inputs; |
| 324 | + | |
| 325 | + if (!name) | |
| 326 | + return AVERROR(EINVAL); | |
| 327 | + | |
| 321 | 328 | if (!input) { |
| 322 | 329 | av_log(log_ctx, AV_LOG_ERROR, |
| 323 | − "No output pad can be associated to link label '%s'.\n", | |
| 324 | − name); | |
| 330 | + "No output pad can be associated to link label '%s'.\n", name); | |
| 331 | + av_free(name); | |
| 325 | 332 | return AVERROR(EINVAL); |
| 326 | 333 | } |
| 327 | 334 | *curr_inputs = (*curr_inputs)->next; |
| 328 | 335 | |
| 329 | − if (!name) | |
| 330 | − return AVERROR(EINVAL); | |
| 331 | − | |
| 332 | 336 | /* First check if the label is not in the open_inputs list */ |
| 333 | 337 | match = extract_inout(name, open_inputs); |
| 334 | 338 | |
| 335 | 339 | if (match) { |
| 336 | 340 | if ((ret = link_filter(input->filter_ctx, input->pad_idx, |
| 337 | − match->filter_ctx, match->pad_idx, log_ctx)) < 0) | |
| 341 | + match->filter_ctx, match->pad_idx, log_ctx)) < 0) { | |
| 342 | + av_free(name); | |
| 338 | 343 | return ret; |
| 344 | + } | |
| 339 | 345 | av_free(match->name); |
| 340 | 346 | av_free(name); |
| 341 | 347 | av_free(match); |