[FFmpeg-cvslog] avfilter: fix leaks on error in ff_filter_frame

Vittorio Giovara git at videolan.org
Fri Jan 10 03:57:08 CET 2014


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Wed Dec 18 11:45:01 2013 +0100| [abb5e37f64c48bba8bd0fde2bada0f7544defa24] | committer: Vittorio Giovara

avfilter: fix leaks on error in ff_filter_frame

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=abb5e37f64c48bba8bd0fde2bada0f7544defa24
---

 libavfilter/avfilter.c |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index b18c0cb..f02358f 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -729,7 +729,8 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
 {
     int (*filter_frame)(AVFilterLink *, AVFrame *);
     AVFilterPad *dst = link->dstpad;
-    AVFrame *out;
+    AVFrame *out = NULL;
+    int ret;
 
     FF_DPRINTF_START(NULL, filter_frame);
     ff_dlog_link(NULL, link, 1);
@@ -748,13 +749,18 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
         case AVMEDIA_TYPE_AUDIO:
             out = ff_get_audio_buffer(link, frame->nb_samples);
             break;
-        default: return AVERROR(EINVAL);
+        default:
+            ret = AVERROR(EINVAL);
+            goto fail;
         }
         if (!out) {
-            av_frame_free(&frame);
-            return AVERROR(ENOMEM);
+            ret = AVERROR(ENOMEM);
+            goto fail;
         }
-        av_frame_copy_props(out, frame);
+
+        ret = av_frame_copy_props(out, frame);
+        if (ret < 0)
+            goto fail;
 
         switch (link->type) {
         case AVMEDIA_TYPE_VIDEO:
@@ -767,7 +773,9 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
                             av_get_channel_layout_nb_channels(frame->channel_layout),
                             frame->format);
             break;
-        default: return AVERROR(EINVAL);
+        default:
+            ret = AVERROR(EINVAL);
+            goto fail;
         }
 
         av_frame_free(&frame);
@@ -775,6 +783,11 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
         out = frame;
 
     return filter_frame(link, out);
+
+fail:
+    av_frame_free(&out);
+    av_frame_free(&frame);
+    return ret;
 }
 
 const AVClass *avfilter_get_class(void)



More information about the ffmpeg-cvslog mailing list