From patchwork Wed Feb 8 23:23:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 2456 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp51849vsb; Wed, 8 Feb 2017 15:23:40 -0800 (PST) X-Received: by 10.28.234.66 with SMTP id i63mr20378248wmh.43.1486596220449; Wed, 08 Feb 2017 15:23:40 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p10si4019311wmb.167.2017.02.08.15.23.39; Wed, 08 Feb 2017 15:23:40 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 14BC2689C81; Thu, 9 Feb 2017 01:23:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 14F7F689931 for ; Thu, 9 Feb 2017 01:23:27 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 10B12102CF0; Thu, 9 Feb 2017 00:23:30 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YX-ZNLIbNxwn; Thu, 9 Feb 2017 00:23:28 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 66BA0102CA0; Thu, 9 Feb 2017 00:23:28 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Feb 2017 00:23:23 +0100 Message-Id: <20170208232325.15839-1-cus@passwd.hu> X-Mailer: git-send-email 2.10.2 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/fifo: assert on disallowed message type and state combinations X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes Coverity CID 1396277. Signed-off-by: Marton Balint --- libavformat/fifo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 8f525e5..2cbe5c5 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -19,6 +19,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/avassert.h" #include "libavutil/opt.h" #include "libavutil/time.h" #include "libavutil/thread.h" @@ -207,7 +208,7 @@ static int fifo_thread_write_trailer(FifoThreadContext *ctx) static int fifo_thread_dispatch_message(FifoThreadContext *ctx, FifoMessage *msg) { - int ret; + int ret = AVERROR(EINVAL); if (!ctx->header_written) { ret = fifo_thread_write_header(ctx); @@ -217,6 +218,7 @@ static int fifo_thread_dispatch_message(FifoThreadContext *ctx, FifoMessage *msg switch(msg->type) { case FIFO_WRITE_HEADER: + av_assert0(ret >= 0); return ret; case FIFO_WRITE_PACKET: return fifo_thread_write_packet(ctx, &msg->pkt); @@ -224,6 +226,7 @@ static int fifo_thread_dispatch_message(FifoThreadContext *ctx, FifoMessage *msg return fifo_thread_flush_output(ctx); } + av_assert0(0); return AVERROR(EINVAL); }