From 7894a4d85f81be333aa1fab3b630bca078a4ce51 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sun, 25 Oct 2015 19:59:06 +0100 Subject: [PATCH] [transcode] Don't push NULL frames to filtergraph when flushing, can lead to segfault --- src/transcode.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/transcode.c b/src/transcode.c index d0bee27d..f7b70aa2 100644 --- a/src/transcode.c +++ b/src/transcode.c @@ -373,11 +373,14 @@ filter_encode_write_frame(struct encode_ctx *ctx, AVFrame *frame, unsigned int s int ret; // Push the decoded frame into the filtergraph - ret = av_buffersrc_add_frame_flags(ctx->filter_ctx[stream_index].buffersrc_ctx, frame, 0); - if (ret < 0) + if (frame) { - DPRINTF(E_LOG, L_XCODE, "Error while feeding the filtergraph\n"); - return -1; + ret = av_buffersrc_add_frame_flags(ctx->filter_ctx[stream_index].buffersrc_ctx, frame, 0); + if (ret < 0) + { + DPRINTF(E_LOG, L_XCODE, "Error while feeding the filtergraph\n"); + return -1; + } } // Pull filtered frames from the filtergraph @@ -424,11 +427,14 @@ filter_encode_write_frame(struct encode_ctx *ctx, AVFrame *frame, unsigned int s enc_ctx = ctx->ofmt_ctx->streams[stream_index]->codec; // Push the decoded frame into the filtergraph - ret = av_buffersrc_write_frame(ctx->filter_ctx[stream_index].buffersrc_ctx, frame); - if (ret < 0) + if (frame) { - DPRINTF(E_LOG, L_XCODE, "Error while feeding the filtergraph\n"); - return -1; + ret = av_buffersrc_write_frame(ctx->filter_ctx[stream_index].buffersrc_ctx, frame); + if (ret < 0) + { + DPRINTF(E_LOG, L_XCODE, "Error while feeding the filtergraph\n"); + return -1; + } } // Pull filtered frames from the filtergraph