From patchwork Tue Jul 26 10:40:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sebechlebskyjan@gmail.com X-Patchwork-Id: 2 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp1220935vsd; Tue, 26 Jul 2016 03:40:37 -0700 (PDT) X-Received: by 10.194.110.162 with SMTP id ib2mr20034172wjb.163.1469529637754; Tue, 26 Jul 2016 03:40:37 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m80si726114wmi.50.2016.07.26.03.40.37; Tue, 26 Jul 2016 03:40:37 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@gmail.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; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F04668A405; Tue, 26 Jul 2016 13:40:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F3F6668A3D4 for ; Tue, 26 Jul 2016 13:40:17 +0300 (EEST) Received: by mail-wm0-f66.google.com with SMTP id i5so998034wmg.2 for ; Tue, 26 Jul 2016 03:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jQ4Axhw2eilbUT12/S80ACoO49qvGXBeeqrDfEPwDtA=; b=OCXL7zKRLg1fzX0WI/OVUaMNv+S8+kuqiDGiH87Z0GPilVnAA+2zlF9f/o/gfGj4Vh wsK4+4v67IhkyjohqjETAbOWc1S/1fptj5qP+pxKwOcb45bDTS4SLErQkQcvRz15WQy5 sWtWL5apyZ4k6JSgWMw4/tgWcvqHf5RcOrf3o2tUkh6eC0Ti3fgURpt6XBK2wB6a3l0S FgjuuJgj8D46i9FxprOt6WWGXfsub8NMvweTA+y0ihKd9XtW6kxQlCF42iH2iOifTNah iGq4YHpfZU9VzEQqw6dNo/QecSW1xdy5llk0UBVStdGbuceCmcMI+JydAEUWt7n1avfr nJdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jQ4Axhw2eilbUT12/S80ACoO49qvGXBeeqrDfEPwDtA=; b=PxqD+FV2JXPpZ/z1zzePIeMVxIyyhUg6M7/Pp/VdZFb51thHaY+ZDnJJNRSJRYkfhR YV6T/zALBXX1Tc64QvwVPVwAHWataSbOzts89FM5QoElvESemwKK6swBhs1eGXzf91+6 Vl488z0O46B6f/ovIyqvnOp3OJBd8VK0vW0c8KjAMROYRQYvxM/UnQ8BXE/HJ4vR7u+W tDwma0BoMHweqA4dY8YnebAsiKXOmkLJzOC+8J/YK6ZbzMlSh0p+dBpNsIBRRwtcvezl RzdgHT9Pf38Y75ra5pjUkPu78kyzCTMiMySsDb2GtdHxIZq9T5Mh66+6jxwnEPlmELYk ZFEA== X-Gm-Message-State: AEkoousXGYjxnplvvE/4kb1rSksaY1dtD8T62apvSE+LzAa1PoPFEhz9IRrvMxlpsgIWuQ== X-Received: by 10.194.54.166 with SMTP id k6mr22645193wjp.48.1469529621391; Tue, 26 Jul 2016 03:40:21 -0700 (PDT) Received: from localhost.localdomain (157.174.broadband3.iol.cz. [85.70.174.157]) by smtp.gmail.com with ESMTPSA id k186sm29779166wmd.13.2016.07.26.03.40.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Jul 2016 03:40:20 -0700 (PDT) From: sebechlebskyjan@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 26 Jul 2016 12:40:08 +0200 Message-Id: <1469529608-1845-2-git-send-email-sebechlebskyjan@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469529608-1845-1-git-send-email-sebechlebskyjan@gmail.com> References: <20160725151438.GA17505@phare.normalesup.org> <1469529608-1845-1-git-send-email-sebechlebskyjan@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 2/2] avcodec/bsf: Forbid packet without payload in av_bsf_send_packet 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: Jan Sebechlebsky MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Jan Sebechlebsky Signed-off-by: Jan Sebechlebsky --- libavcodec/avcodec.h | 3 ++- libavcodec/bsf.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ca8dba8..36f7935 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -5898,7 +5898,8 @@ int av_bsf_init(AVBSFContext *ctx); * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or * AVERROR_EOF. * - * @param pkt the packet to filter. The bitstream filter will take ownership of + * @param pkt the packet to filter. pkt must contain some payload (i.e data or + * side data must be present in pkt). The bitstream filter will take ownership of * the packet and reset the contents of pkt. pkt is not touched if an error occurs. * This parameter may be NULL, which signals the end of the stream (i.e. no more * packets will be sent). That will cause the filter to output any packets it diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 9b9ada7..8e36861 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -21,6 +21,7 @@ #include "libavutil/log.h" #include "libavutil/mem.h" #include "libavutil/opt.h" +#include "libavutil/avassert.h" #include "avcodec.h" #include "bsf.h" @@ -177,6 +178,8 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) return 0; } + av_assert0(pkt->data || pkt->side_data); + if (ctx->internal->eof) { av_log(ctx, AV_LOG_ERROR, "A non-NULL packet sent after an EOF.\n"); return AVERROR(EINVAL);