aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-07-15 11:16:53 +0200
committerAnton Khirnov <anton@khirnov.net>2012-07-22 09:14:05 +0200
commit1dc42050185d63c1de5d16146fbaee92640af187 (patch)
treee53dbbfc52894acf4efd526b9ddcaf1d0b87d94d
parent80e4ed279b3abe9f5356e2b56255b2aa64527345 (diff)
downloadffmpeg-1dc42050185d63c1de5d16146fbaee92640af187.tar.gz
lavfi: check all avfilter_ref_buffer() calls for errors.
-rw-r--r--libavfilter/fifo.c3
-rw-r--r--libavfilter/split.c17
-rw-r--r--libavfilter/vf_delogo.c9
-rw-r--r--libavfilter/vf_frei0r.c9
-rw-r--r--libavfilter/vf_gradfun.c9
-rw-r--r--libavfilter/vf_overlay.c3
-rw-r--r--libavfilter/vf_pixdesctest.c9
-rw-r--r--libavfilter/vf_scale.c14
-rw-r--r--libavfilter/vf_select.c6
-rw-r--r--libavfilter/vf_transpose.c6
-rw-r--r--libavfilter/vf_vflip.c3
-rw-r--r--libavfilter/vf_yadif.c11
-rw-r--r--libavfilter/video.c7
-rw-r--r--libavfilter/vsrc_color.c9
-rw-r--r--libavfilter/vsrc_movie.c5
15 files changed, 100 insertions, 20 deletions
diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index 8264d5302e..3226a0ddbe 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -169,6 +169,9 @@ static int return_audio_frame(AVFilterContext *ctx)
queue_pop(s);
} else {
buf_out = avfilter_ref_buffer(head, AV_PERM_READ);
+ if (!buf_out)
+ return AVERROR(ENOMEM);
+
buf_out->audio->nb_samples = link->request_samples;
buffer_offset(link, head, link->request_samples);
}
diff --git a/libavfilter/split.c b/libavfilter/split.c
index 469f69d76a..084d555f1a 100644
--- a/libavfilter/split.c
+++ b/libavfilter/split.c
@@ -69,8 +69,11 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
int i, ret = 0;
for (i = 0; i < ctx->nb_outputs; i++) {
- ret = ff_start_frame(ctx->outputs[i],
- avfilter_ref_buffer(picref, ~AV_PERM_WRITE));
+ AVFilterBufferRef *buf_out = avfilter_ref_buffer(picref, ~AV_PERM_WRITE);
+ if (!buf_out)
+ return AVERROR(ENOMEM);
+
+ ret = ff_start_frame(ctx->outputs[i], buf_out);
if (ret < 0)
break;
}
@@ -126,8 +129,14 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
int i, ret = 0;
for (i = 0; i < ctx->nb_outputs; i++) {
- ret = ff_filter_samples(inlink->dst->outputs[i],
- avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE));
+ AVFilterBufferRef *buf_out = avfilter_ref_buffer(samplesref,
+ ~AV_PERM_WRITE);
+ if (!buf_out) {
+ ret = AVERROR(ENOMEM);
+ break;
+ }
+
+ ret = ff_filter_samples(inlink->dst->outputs[i], buf_out);
if (ret < 0)
break;
}
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 81f33b727e..343585fc5e 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -217,7 +217,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
{
AVFilterLink *outlink = inlink->dst->outputs[0];
- AVFilterBufferRef *outpicref = NULL;
+ AVFilterBufferRef *outpicref = NULL, *for_next_filter;
int ret = 0;
if (inpicref->perms & AV_PERM_PRESERVE) {
@@ -235,7 +235,12 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
return AVERROR(ENOMEM);
}
- ret = ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
+ for_next_filter = avfilter_ref_buffer(outpicref, ~0);
+ if (for_next_filter)
+ ret = ff_start_frame(outlink, for_next_filter);
+ else
+ ret = AVERROR(ENOMEM);
+
if (ret < 0) {
avfilter_unref_bufferp(&outpicref);
return ret;
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index f5e9128d31..152795f5b6 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -438,13 +438,20 @@ static int source_request_frame(AVFilterLink *outlink)
{
Frei0rContext *frei0r = outlink->src->priv;
AVFilterBufferRef *picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
+ AVFilterBufferRef *buf_out;
int ret;
picref->video->pixel_aspect = (AVRational) {1, 1};
picref->pts = frei0r->pts++;
picref->pos = -1;
- ret = ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
+ buf_out = avfilter_ref_buffer(picref, ~0);
+ if (!buf_out) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ ret = ff_start_frame(outlink, buf_out);
if (ret < 0)
goto fail;
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index d73e833865..52dcb7092f 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -183,7 +183,7 @@ static int config_input(AVFilterLink *inlink)
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
{
AVFilterLink *outlink = inlink->dst->outputs[0];
- AVFilterBufferRef *outpicref = NULL;
+ AVFilterBufferRef *outpicref = NULL, *for_next_filter;
int ret = 0;
if (inpicref->perms & AV_PERM_PRESERVE) {
@@ -200,7 +200,12 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
return AVERROR(ENOMEM);
}
- ret = ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
+ for_next_filter = avfilter_ref_buffer(outpicref, ~0);
+ if (for_next_filter)
+ ret = ff_start_frame(outlink, for_next_filter);
+ else
+ ret = AVERROR(ENOMEM);
+
if (ret < 0) {
avfilter_unref_bufferp(&outpicref);
return ret;
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 951ea7a4f6..14304c1918 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -213,6 +213,9 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
AVFilterContext *ctx = inlink->dst;
OverlayContext *over = ctx->priv;
+ if (!outpicref)
+ return AVERROR(ENOMEM);
+
outpicref->pts = av_rescale_q(outpicref->pts, ctx->inputs[MAIN]->time_base,
ctx->outputs[0]->time_base);
diff --git a/libavfilter/vf_pixdesctest.c b/libavfilter/vf_pixdesctest.c
index caf0852045..11905e625c 100644
--- a/libavfilter/vf_pixdesctest.c
+++ b/libavfilter/vf_pixdesctest.c
@@ -55,7 +55,7 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
PixdescTestContext *priv = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
- AVFilterBufferRef *outpicref;
+ AVFilterBufferRef *outpicref, *for_next_filter;
int i, ret = 0;
outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE,
@@ -80,7 +80,12 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
priv->pix_desc->flags & PIX_FMT_PSEUDOPAL)
memcpy(outpicref->data[1], outpicref->data[1], 256*4);
- ret = ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
+ for_next_filter = avfilter_ref_buffer(outpicref, ~0);
+ if (for_next_filter)
+ ret = ff_start_frame(outlink, for_next_filter);
+ else
+ ret = AVERROR(ENOMEM);
+
if (ret < 0) {
avfilter_unref_bufferp(&outpicref);
return ret;
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 73f31a65fd..66005303f5 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -256,11 +256,14 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{
ScaleContext *scale = link->dst->priv;
AVFilterLink *outlink = link->dst->outputs[0];
- AVFilterBufferRef *outpicref;
+ AVFilterBufferRef *outpicref, *for_next_filter;
int ret = 0;
if (!scale->sws) {
- return ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
+ outpicref = avfilter_ref_buffer(picref, ~0);
+ if (!outpicref)
+ return AVERROR(ENOMEM);
+ return ff_start_frame(outlink, outpicref);
}
scale->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w;
@@ -281,7 +284,12 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
INT_MAX);
scale->slice_y = 0;
- ret = ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0));
+ for_next_filter = avfilter_ref_buffer(outpicref, ~0);
+ if (for_next_filter)
+ ret = ff_start_frame(outlink, for_next_filter);
+ else
+ ret = AVERROR(ENOMEM);
+
if (ret < 0) {
avfilter_unref_bufferp(&outpicref);
return ret;
diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c
index b4a424e1d2..59030ebced 100644
--- a/libavfilter/vf_select.c
+++ b/libavfilter/vf_select.c
@@ -233,6 +233,7 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
select->select = select_frame(inlink->dst, picref);
if (select->select) {
+ AVFilterBufferRef *buf_out;
/* frame was requested through poll_frame */
if (select->cache_frames) {
if (!av_fifo_space(select->pending_frames))
@@ -243,7 +244,10 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
sizeof(picref), NULL);
return 0;
}
- return ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0));
+ buf_out = avfilter_ref_buffer(picref, ~0);
+ if (!buf_out)
+ return AVERROR(ENOMEM);
+ return ff_start_frame(inlink->dst->outputs[0], buf_out);
}
return 0;
diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 49b54d760b..90f08e42cd 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -120,6 +120,7 @@ static int config_props_output(AVFilterLink *outlink)
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
{
AVFilterLink *outlink = inlink->dst->outputs[0];
+ AVFilterBufferRef *buf_out;
outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE,
outlink->w, outlink->h);
@@ -135,7 +136,10 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
outlink->out_buf->video->pixel_aspect.den = picref->video->pixel_aspect.num;
}
- return ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
+ buf_out = avfilter_ref_buffer(outlink->out_buf, ~0);
+ if (!buf_out)
+ return AVERROR(ENOMEM);
+ return ff_start_frame(outlink, buf_out);
}
static int end_frame(AVFilterLink *inlink)
diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c
index dc7604c52a..b3143229b1 100644
--- a/libavfilter/vf_vflip.c
+++ b/libavfilter/vf_vflip.c
@@ -70,6 +70,9 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref)
AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
int i;
+ if (!outpicref)
+ return AVERROR(ENOMEM);
+
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 1025ba12c7..db4956c2cc 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -224,14 +224,18 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
if (yadif->auto_enable && !yadif->cur->video->interlaced) {
yadif->out = avfilter_ref_buffer(yadif->cur, AV_PERM_READ);
+ if (!yadif->out)
+ return AVERROR(ENOMEM);
+
avfilter_unref_bufferp(&yadif->prev);
if (yadif->out->pts != AV_NOPTS_VALUE)
yadif->out->pts *= 2;
return ff_start_frame(ctx->outputs[0], yadif->out);
}
- if (!yadif->prev)
- yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ);
+ if (!yadif->prev &&
+ !(yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ)))
+ return AVERROR(ENOMEM);
yadif->out = ff_get_video_buffer(ctx->outputs[0], AV_PERM_WRITE | AV_PERM_PRESERVE |
AV_PERM_REUSE, link->w, link->h);
@@ -282,6 +286,9 @@ static int request_frame(AVFilterLink *link)
if (ret == AVERROR_EOF && yadif->next) {
AVFilterBufferRef *next = avfilter_ref_buffer(yadif->next, AV_PERM_READ);
+ if (!next)
+ return AVERROR(ENOMEM);
+
next->pts = yadif->next->pts * 2 - yadif->cur->pts;
start_frame(link->src->inputs[0], next);
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 8dd5bf4272..6e5063778a 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -176,12 +176,17 @@ static int default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
outlink = inlink->dst->outputs[0];
if (outlink) {
+ AVFilterBufferRef *buf_out;
outlink->out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
if (!outlink->out_buf)
return AVERROR(ENOMEM);
avfilter_copy_buffer_ref_props(outlink->out_buf, picref);
- return ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
+ buf_out = avfilter_ref_buffer(outlink->out_buf, ~0);
+ if (!buf_out)
+ return AVERROR(ENOMEM);
+
+ return ff_start_frame(outlink, buf_out);
}
return 0;
}
diff --git a/libavfilter/vsrc_color.c b/libavfilter/vsrc_color.c
index c17f54f39d..0fa6853189 100644
--- a/libavfilter/vsrc_color.c
+++ b/libavfilter/vsrc_color.c
@@ -142,13 +142,20 @@ static int color_request_frame(AVFilterLink *link)
{
ColorContext *color = link->src->priv;
AVFilterBufferRef *picref = ff_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h);
+ AVFilterBufferRef *buf_out;
int ret;
picref->video->pixel_aspect = (AVRational) {1, 1};
picref->pts = color->pts++;
picref->pos = -1;
- ret = ff_start_frame(link, avfilter_ref_buffer(picref, ~0));
+ buf_out = avfilter_ref_buffer(picref, ~0);
+ if (!buf_out) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ ret = ff_start_frame(link, buf_out);
if (ret < 0)
goto fail;
diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c
index b0f191fe8e..926d57dff5 100644
--- a/libavfilter/vsrc_movie.c
+++ b/libavfilter/vsrc_movie.c
@@ -289,6 +289,11 @@ static int request_frame(AVFilterLink *outlink)
return ret;
outpicref = avfilter_ref_buffer(movie->picref, ~0);
+ if (!outpicref) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
ret = ff_start_frame(outlink, outpicref);
if (ret < 0)
goto fail;