History

avfilter: fix leaks on error in ff_filter_frame

Vittorio Giovara committed 12 years ago

Commit abb5e371 parent 56557321 file · +19 −6Browse files

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

Unified · Split

libavfilter/avfilter.c+19−6
@@ -729,7 +729,8 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 728 unmodified lines
729729 {
730730 int (*filter_frame)(AVFilterLink *, AVFrame *);
731731 AVFilterPad *dst = link->dstpad;
732− AVFrame *out;
732+ AVFrame *out = NULL;
733+ int ret;
733734
734735 FF_DPRINTF_START(NULL, filter_frame);
735736 ff_dlog_link(NULL, link, 1);
@@ -748,13 +749,18 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 12 unmodified lines
748749 case AVMEDIA_TYPE_AUDIO:
749750 out = ff_get_audio_buffer(link, frame->nb_samples);
750751 break;
751− default: return AVERROR(EINVAL);
752+ default:
753+ ret = AVERROR(EINVAL);
754+ goto fail;
752755 }
753756 if (!out) {
754− av_frame_free(&frame);
755− return AVERROR(ENOMEM);
757+ ret = AVERROR(ENOMEM);
758+ goto fail;
756759 }
757− av_frame_copy_props(out, frame);
760+
761+ ret = av_frame_copy_props(out, frame);
762+ if (ret < 0)
763+ goto fail;
758764
759765 switch (link->type) {
760766 case AVMEDIA_TYPE_VIDEO:
@@ -767,7 +773,9 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 6 unmodified lines
767773 av_get_channel_layout_nb_channels(frame->channel_layout),
768774 frame->format);
769775 break;
770− default: return AVERROR(EINVAL);
776+ default:
777+ ret = AVERROR(EINVAL);
778+ goto fail;
771779 }
772780
773781 av_frame_free(&frame);
@@ -775,6 +783,11 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 1 unmodified line
775783 out = frame;
776784
777785 return filter_frame(link, out);
786+
787+fail:
788+ av_frame_free(&out);
789+ av_frame_free(&frame);
790+ return ret;
778791 }
779792
780793 const AVClass *avfilter_get_class(void)

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