History

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.

Andrew Kelley committed 12 years ago

Commit d3cfd7a1 parent a9aee081 file · +15 −3Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/af_compand.c+15−3
@@ -71,6 +71,8 @@ typedef struct CompandContext { · 70 unmodified lines
7171 int64_t pts;
7272
7373 int (*compand)(AVFilterContext *ctx, AVFrame *frame);
74+ /* set by filter_frame() to signal an output frame to request_frame() */
75+ int got_output;
7476 } CompandContext;
7577
7678 #define OFFSET(x) offsetof(CompandContext, x)
@@ -287,7 +289,15 @@ static int compand_delay(AVFilterContext *ctx, AVFrame *frame) · 210 unmodified lines
287289 s->delay_index = dindex;
288290
289291 av_frame_free(&frame);
290− return out_frame ? ff_filter_frame(ctx->outputs[0], out_frame) : 0;
292+
293+ if (out_frame) {
294+ err = ff_filter_frame(ctx->outputs[0], out_frame);
295+ if (err >= 0)
296+ s->got_output = 1;
297+ return err;
298+ }
299+
300+ return 0;
291301 }
292302
293303 static int compand_drain(AVFilterLink *outlink)
@@ -559,9 +569,11 @@ static int request_frame(AVFilterLink *outlink) · 265 unmodified lines
559569 {
560570 AVFilterContext *ctx = outlink->src;
561571 CompandContext *s = ctx->priv;
562− int ret;
572+ int ret = 0;
563573
564− ret = ff_request_frame(ctx->inputs[0]);
574+ s->got_output = 0;
575+ while (ret >= 0 && !s->got_output)
576+ ret = ff_request_frame(ctx->inputs[0]);
565577
566578 if (ret == AVERROR_EOF && s->delay_count)
567579 ret = compand_drain(outlink);

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