History

avfilter: fix leaks on error in ff_filter_frame

Vittorio Giovara committed 12 years ago

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

Unified · Split

libavfilter/avfilter.c+19−6
@@ -729,7 +729,8 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 728 unmodified lines
729{729{
730 int (*filter_frame)(AVFilterLink *, AVFrame *);730 int (*filter_frame)(AVFilterLink *, AVFrame *);
731 AVFilterPad *dst = link->dstpad;731 AVFilterPad *dst = link->dstpad;
732 AVFrame *out;732 AVFrame *out = NULL;
733 int ret;
733 734
734 FF_DPRINTF_START(NULL, filter_frame);735 FF_DPRINTF_START(NULL, filter_frame);
735 ff_dlog_link(NULL, link, 1);736 ff_dlog_link(NULL, link, 1);
@@ -748,13 +749,18 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 12 unmodified lines
748 case AVMEDIA_TYPE_AUDIO:749 case AVMEDIA_TYPE_AUDIO:
749 out = ff_get_audio_buffer(link, frame->nb_samples);750 out = ff_get_audio_buffer(link, frame->nb_samples);
750 break;751 break;
751 default: return AVERROR(EINVAL);752 default:
753 ret = AVERROR(EINVAL);
754 goto fail;
752 }755 }
753 if (!out) {756 if (!out) {
754 av_frame_free(&frame);757 ret = AVERROR(ENOMEM);
755 return AVERROR(ENOMEM);758 goto fail;
756 }759 }
757 av_frame_copy_props(out, frame);760
761 ret = av_frame_copy_props(out, frame);
762 if (ret < 0)
763 goto fail;
758 764
759 switch (link->type) {765 switch (link->type) {
760 case AVMEDIA_TYPE_VIDEO:766 case AVMEDIA_TYPE_VIDEO:
@@ -767,7 +773,9 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 6 unmodified lines
767 av_get_channel_layout_nb_channels(frame->channel_layout),773 av_get_channel_layout_nb_channels(frame->channel_layout),
768 frame->format);774 frame->format);
769 break;775 break;
770 default: return AVERROR(EINVAL);776 default:
777 ret = AVERROR(EINVAL);
778 goto fail;
771 }779 }
772 780
773 av_frame_free(&frame);781 av_frame_free(&frame);
@@ -775,6 +783,11 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 1 unmodified line
775 out = frame;783 out = frame;
776 784
777 return filter_frame(link, out);785 return filter_frame(link, out);
786
787fail:
788 av_frame_free(&out);
789 av_frame_free(&frame);
790 return ret;
778}791}
779 792
780const AVClass *avfilter_get_class(void)793const 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