Commit d3cfd7af authored by Andrew Kelley's avatar Andrew Kelley Committed by Anton Khirnov

af_compand: make sure request_frame always outputs at least one frame

This fixes a segmentation fault because request_frame in fifo.c assumes
that the call to ff_request_frame will populate fifo->root.next.
Before, it was possible for request_frame in af_compand to not do this,
resulting in a null pointer access. Now, request_frame in af_compand
always will return at least one frame or an error, as per the API
specifications in avfilter.h for request_frame.
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent a9aee08d
...@@ -71,6 +71,8 @@ typedef struct CompandContext { ...@@ -71,6 +71,8 @@ typedef struct CompandContext {
int64_t pts; int64_t pts;
int (*compand)(AVFilterContext *ctx, AVFrame *frame); int (*compand)(AVFilterContext *ctx, AVFrame *frame);
/* set by filter_frame() to signal an output frame to request_frame() */
int got_output;
} CompandContext; } CompandContext;
#define OFFSET(x) offsetof(CompandContext, x) #define OFFSET(x) offsetof(CompandContext, x)
...@@ -287,7 +289,15 @@ static int compand_delay(AVFilterContext *ctx, AVFrame *frame) ...@@ -287,7 +289,15 @@ static int compand_delay(AVFilterContext *ctx, AVFrame *frame)
s->delay_index = dindex; s->delay_index = dindex;
av_frame_free(&frame); av_frame_free(&frame);
return out_frame ? ff_filter_frame(ctx->outputs[0], out_frame) : 0;
if (out_frame) {
err = ff_filter_frame(ctx->outputs[0], out_frame);
if (err >= 0)
s->got_output = 1;
return err;
}
return 0;
} }
static int compand_drain(AVFilterLink *outlink) static int compand_drain(AVFilterLink *outlink)
...@@ -559,8 +569,10 @@ static int request_frame(AVFilterLink *outlink) ...@@ -559,8 +569,10 @@ static int request_frame(AVFilterLink *outlink)
{ {
AVFilterContext *ctx = outlink->src; AVFilterContext *ctx = outlink->src;
CompandContext *s = ctx->priv; CompandContext *s = ctx->priv;
int ret; int ret = 0;
s->got_output = 0;
while (ret >= 0 && !s->got_output)
ret = ff_request_frame(ctx->inputs[0]); ret = ff_request_frame(ctx->inputs[0]);
if (ret == AVERROR_EOF && s->delay_count) if (ret == AVERROR_EOF && s->delay_count)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment