From patchwork Fri Dec 6 13:55:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andriy Gelman X-Patchwork-Id: 16633 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 944B244ADCF for ; Fri, 6 Dec 2019 16:02:27 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73EB868AD97; Fri, 6 Dec 2019 16:02:27 +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 EC17368B5DE for ; Fri, 6 Dec 2019 16:02:20 +0200 (EET) Received: by mail-oi1-f194.google.com with SMTP id x14so2672258oic.10 for ; Fri, 06 Dec 2019 06:02:20 -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=ED7joIEfPfNzk1gfA05BK7tEsOIOzVZ/8BJRdAE+lmc=; b=N2aRphdSSOGYSj0b65RxL52Z7ea9BOEuiAPY3q4UFop+LDfzF9XAncNkwAvx0EGXwm WjqyUU+dhjtyz9mNFK6yi1TKC/En7XtjK+M/PXYtmCkELeGMTFNVZUcFzbjRBaz61jfx BLIwojUuGO5O6u7Wvx8HUV7RFOiQL/Dp6SP5IMZW7BiJ3UIDpMeKE1vpRFpO2gKFjHY2 nnMZuhp/9j9+EPY0nsd5Nh41tDmhLdqXYJ2x92+7vsvnBrq1xKimDYVhObvcsp41BROu GzVkt6cLYAsVKOCLWVopVSwIyPfMJoBY2mGuyo8LR6nQN9bKwus0/6MuxnPjWKA57ROi 8YTw== 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=ED7joIEfPfNzk1gfA05BK7tEsOIOzVZ/8BJRdAE+lmc=; b=uVtRyDKMJuJgjixqHFEnete63jmdsp+k3K0/sncaKtUZkLibb8pxbFuff4tkjsrCzX syLycbMTRjczwVTqQzG94xXKu6RsEdCEkTI549waAJkkuKO8zxCIV9Yj1GQrwfDzLMuE lDtH0brYoNR3Ev8vYU44kNfMDiQRx3KsRv9INr9xYGobEKnm8vTYHAp4yji5ixq5WeW2 SURByhja3AGh5Pv/+TeHeFgrWmwld3+gSOcorGNfrCau/VEf911QuUAzeLLsrAnYQiTR sF8ggwoa9I1TkTb1oIOcPO2IupZUXG68fFjJo+CylR3sHvbkiCDS5p8h6sWRVdPSr29K tbtw== X-Gm-Message-State: APjAAAVcYkDygQ7XBUWJgZW0WdKuYwktIEO7HaKeO3BqFhH7lxpcVgx8 9wxSjVqLRqdvFdpi0ZZ8G157FtVV X-Google-Smtp-Source: APXvYqyvKhjBFi898OV626B0+U3qDMiR+JSaHdEAxYxDZeCs+GsxLvBR3FqVlMNGb5a31Y8GeIvslA== X-Received: by 2002:aca:b1d4:: with SMTP id a203mr9922529oif.150.1575640557910; Fri, 06 Dec 2019 05:55:57 -0800 (PST) Received: from manj.guest.slb.com ([192.23.22.48]) by smtp.gmail.com with ESMTPSA id t9sm1883753otm.76.2019.12.06.05.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 05:55:57 -0800 (PST) From: Andriy Gelman X-Google-Original-From: Andriy Gelman To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Dec 2019 08:55:41 -0500 Message-Id: <20191206135541.8202-2-andriy.gelman@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206135541.8202-1-andriy.gelman@gmail.com> References: <20191206135541.8202-1-andriy.gelman@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/2] 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 f1e1a45abd1..3ed527d8ac0 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;