History

avfilter: fix graphparser memleaks on error paths

Fixes CID700635, CID700636 and CID732274.

Janne Grunau committed 14 years ago

Commit 285b7061 parent 587874e1 file · +15 −9Browse files

Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t