From patchwork Wed Dec 4 00:04:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andriy Gelman X-Patchwork-Id: 16579 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4872144AF0A for ; Wed, 4 Dec 2019 02:04:29 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2FA6C68B4C7; Wed, 4 Dec 2019 02:04:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 24AA968B492 for ; Wed, 4 Dec 2019 02:04:23 +0200 (EET) Received: by mail-oi1-f194.google.com with SMTP id a67so5154958oib.6 for ; Tue, 03 Dec 2019 16:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rzX98ivmclcBPMVoRJYm+18Td/id+GdRYKiE3gXVu88=; b=U4xh9p14O4LlrJaSvrLHSvtIGMIvd62VrL8GpQofdmt/zjKAvzPCBsqv6YhDKUn0Zn FzQeaUjLrOe5aqYHLdAibIJT9mLyhx6SbUSYxyzL7ddp0AM2Mce7JNEhea9UYqns/ya0 nocNm2QyRWYK74oGhoV+0fX1ct7+GVYsNsNKYzQKB0UZMxMxMadoi2nTZNXFlYuuaJj5 gaJYG08yg2H3LMWMycL1M76Hy2cn2Xp8A44FpBmCAVzYwO7Rg5ovDYIWuIi57ArGYffD miacU9SUH6yAP0GQLvQBZV6yHrdvz+V0i5i4x13klpcRCg48meuESEVuifQvAhrtXHwh G/Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rzX98ivmclcBPMVoRJYm+18Td/id+GdRYKiE3gXVu88=; b=oJsg5mnxlf8O1CL8qsoUIivcn2kuyXVTdsXWqA9aVxOpq4ev6vUKmjUcd3wv8wriek E6cODGt5GX6lCKGBlqjNf1z4Ho4NLYaihE4+ZY3IocsusPGmYpt8gS5v/qdxp/psVu0A XWPIaTCGSBxRL4xNmGM7KGi0TyAqS0radhZDq4vU+gjhkrfzwkeMFnWOf5ssV7E+eqlY GulAjaEgppJZQmpu1p0hz9qmgFDqmP9UK8q7/fNuR/o2++XFf5tC8BFWaS0+x6pXfYyh qKvn2qpCh7OEOCmI4vdnugipG/B44r9kPA2u05XGuUQ3FvfptVfrvqT4i+HuitbzMorC 6vJg== X-Gm-Message-State: APjAAAXZ27ll5Q0roK/jxnN2DTfu5SIwheq5sKdFjxwwu53G1hlzYTns fkVTTQBmaQpGj1XpxeCBecwTtkwA X-Google-Smtp-Source: APXvYqx7FrETb6vf8CNiG6ceAIFF1E2yPQ5AhQgIWmMUnp45dls4S0W9ikLxKsSea3eR3gsO0I8CRA== X-Received: by 2002:aca:3182:: with SMTP id x124mr302957oix.170.1575417861294; Tue, 03 Dec 2019 16:04:21 -0800 (PST) Received: from manj.guest.slb.com ([192.23.22.48]) by smtp.gmail.com with ESMTPSA id t3sm1611013otq.32.2019.12.03.16.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 16:04:20 -0800 (PST) From: Andriy Gelman X-Google-Original-From: Andriy Gelman To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 Dec 2019 19:04:11 -0500 Message-Id: <20191204000411.29765-3-andriy.gelman@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204000411.29765-1-andriy.gelman@gmail.com> References: <20191204000411.29765-1-andriy.gelman@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/3] lavc/hevc_mp4toannexb: Exit earlier if there is no nalu payload remaining 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: Andriy Gelman Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Andriy Gelman Since the nal unit payload is located after the length prefix, there is no reason to continue reading if there is no nal unit payload remaining. --- libavcodec/hevc_mp4toannexb_bsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c index faf516634b2..c0968b63239 100644 --- a/libavcodec/hevc_mp4toannexb_bsf.c +++ b/libavcodec/hevc_mp4toannexb_bsf.c @@ -136,7 +136,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) bytestream2_init(&gb, in->data, in->size); - while (bytestream2_get_bytes_left(&gb)) { + while (bytestream2_get_bytes_left(&gb) > s->length_size) { uint32_t nalu_size = 0; int nalu_type; int is_irap, add_extradata, extra_size, prev_size;