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
238238 return AVERROR(ENOMEM);
239239
240240 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);
243242 av_free(p->name);
244243 av_free(p);
244+ if (ret < 0)
245+ return ret;
245246 } else {
246247 p->filter_ctx = filt_ctx;
247248 p->pad_idx = pad;
@@ -289,8 +290,10 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, · 41 unmodified lines
289290 av_free(name);
290291 } else {
291292 /* 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);
293295 return AVERROR(ENOMEM);
296+ }
294297 match->name = name;
295298 match->pad_idx = pad;
296299 }
@@ -318,24 +321,27 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, · 21 unmodified lines
318321 AVFilterInOut *match;
319322
320323 AVFilterInOut *input = *curr_inputs;
324+
325+ if (!name)
326+ return AVERROR(EINVAL);
327+
321328 if (!input) {
322329 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);
325332 return AVERROR(EINVAL);
326333 }
327334 *curr_inputs = (*curr_inputs)->next;
328335
329− if (!name)
330− return AVERROR(EINVAL);
331−
332336 /* First check if the label is not in the open_inputs list */
333337 match = extract_inout(name, open_inputs);
334338
335339 if (match) {
336340 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);
338343 return ret;
344+ }
339345 av_free(match->name);
340346 av_free(name);
341347 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