[libav-commits] lavfi: check all ff_get_video_buffer() calls for errors.

Anton Khirnov git at libav.org
Sun Jul 22 09:22:22 CEST 2012


Module: libav
Branch: master
Commit: 8f3a3ce7307e39a030db3bf8d2e525b21e039ca2

Author:    Anton Khirnov <anton at khirnov.net>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Sun Jul 15 11:16:53 2012 +0200

lavfi: check all ff_get_video_buffer() calls for errors.

---

 libavfilter/buffersrc.c    |    3 +++
 libavfilter/vf_frei0r.c    |    3 +++
 libavfilter/vf_pad.c       |    3 +++
 libavfilter/vf_vflip.c     |    3 +++
 libavfilter/vf_yadif.c     |    5 +++++
 libavfilter/vsrc_color.c   |    3 +++
 libavfilter/vsrc_testsrc.c |    3 +++
 7 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 16a38a6..c0cc3a3 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -92,6 +92,9 @@ int av_buffersrc_write_frame(AVFilterContext *buffer_filter, AVFrame *frame)
                                  frame->format);
         buf = ff_get_video_buffer(buffer_filter->outputs[0], AV_PERM_WRITE,
                                   c->w, c->h);
+        if (!buf)
+            return AVERROR(ENOMEM);
+
         av_image_copy(buf->data, buf->linesize, frame->data, frame->linesize,
                       c->pix_fmt, c->w, c->h);
         break;
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 152795f..606c5e2 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -441,6 +441,9 @@ static int source_request_frame(AVFilterLink *outlink)
     AVFilterBufferRef *buf_out;
     int ret;
 
+    if (!picref)
+        return AVERROR(ENOMEM);
+
     picref->video->pixel_aspect = (AVRational) {1, 1};
     picref->pts = frei0r->pts++;
     picref->pos = -1;
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index 262a416..ed2e2e0 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -262,6 +262,9 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int
                                                     h + (pad->h - pad->in_h));
     int plane;
 
+    if (!picref)
+        return NULL;
+
     picref->video->w = w;
     picref->video->h = h;
 
diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c
index b314322..f0fb32a 100644
--- a/libavfilter/vf_vflip.c
+++ b/libavfilter/vf_vflip.c
@@ -52,6 +52,9 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms,
         return ff_default_get_video_buffer(link, perms, w, h);
 
     picref = ff_get_video_buffer(link->dst->outputs[0], perms, w, h);
+    if (!picref)
+        return NULL;
+
     for (i = 0; i < 4; i ++) {
         int vsub = i == 1 || i == 2 ? flip->vsub : 0;
 
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index db4956c..c6d78a5 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -173,6 +173,9 @@ static int return_frame(AVFilterContext *ctx, int is_second)
     if (is_second) {
         yadif->out = ff_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |
                                          AV_PERM_REUSE, link->w, link->h);
+        if (!yadif->out)
+            return AVERROR(ENOMEM);
+
         avfilter_copy_buffer_ref_props(yadif->out, yadif->cur);
         yadif->out->video->interlaced = 0;
     }
@@ -239,6 +242,8 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
 
     yadif->out = ff_get_video_buffer(ctx->outputs[0], AV_PERM_WRITE | AV_PERM_PRESERVE |
                                      AV_PERM_REUSE, link->w, link->h);
+    if (!yadif->out)
+        return AVERROR(ENOMEM);
 
     avfilter_copy_buffer_ref_props(yadif->out, yadif->cur);
     yadif->out->video->interlaced = 0;
diff --git a/libavfilter/vsrc_color.c b/libavfilter/vsrc_color.c
index 0fa6853..ec83f03 100644
--- a/libavfilter/vsrc_color.c
+++ b/libavfilter/vsrc_color.c
@@ -145,6 +145,9 @@ static int color_request_frame(AVFilterLink *link)
     AVFilterBufferRef *buf_out;
     int ret;
 
+    if (!picref)
+        return AVERROR(ENOMEM);
+
     picref->video->pixel_aspect = (AVRational) {1, 1};
     picref->pts                 = color->pts++;
     picref->pos                 = -1;
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 22528b4..42cd58e 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -135,6 +135,9 @@ static int request_frame(AVFilterLink *outlink)
     if (test->max_pts >= 0 && test->pts > test->max_pts)
         return AVERROR_EOF;
     picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h);
+    if (!picref)
+        return AVERROR(ENOMEM);
+
     picref->pts = test->pts++;
     picref->pos = -1;
     picref->video->key_frame = 1;



More information about the libav-commits mailing list