From 6b55aab01a5c2e4c9f2851fdb9b7583f184b5241 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 25 Apr 2012 00:25:18 +0200 Subject: lavfi: create buffer reference in filters which need to access the ref later Also add internal function ff_null_start_frame_keep_ref(). Fix crash when a following filter (e.g. settb) will unref the reference passed by start_frame(), and then the reference is accessed in end_frame() through inlink->cur_buf. --- libavfilter/vf_bbox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libavfilter/vf_bbox.c') diff --git a/libavfilter/vf_bbox.c b/libavfilter/vf_bbox.c index f3d62fb..f8dc625 100644 --- a/libavfilter/vf_bbox.c +++ b/libavfilter/vf_bbox.c @@ -27,6 +27,7 @@ #include "libavutil/timestamp.h" #include "avfilter.h" #include "bbox.h" +#include "internal.h" typedef struct { unsigned int frame; @@ -85,6 +86,7 @@ static void end_frame(AVFilterLink *inlink) av_log(ctx, AV_LOG_INFO, "\n"); bbox->frame++; + avfilter_unref_buffer(picref); avfilter_end_frame(inlink->dst->outputs[0]); } @@ -99,7 +101,7 @@ AVFilter avfilter_vf_bbox = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .get_video_buffer = avfilter_null_get_video_buffer, - .start_frame = avfilter_null_start_frame, + .start_frame = ff_null_start_frame_keep_ref, .end_frame = end_frame, .min_perms = AV_PERM_READ, }, { .name = NULL } -- cgit v1.1