From patchwork Wed Mar 27 11:18:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Felix de Souza via ffmpeg-devel X-Patchwork-Id: 12474 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 1BC88448C86 for ; Wed, 27 Mar 2019 13:20:38 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07DDE68A8BD; Wed, 27 Mar 2019 13:20:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 05EC268A106 for ; Wed, 27 Mar 2019 13:20:32 +0200 (EET) Received: by mail-wr1-f45.google.com with SMTP id j9so18069055wrn.6 for ; Wed, 27 Mar 2019 04:20:32 -0700 (PDT) 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=E+7yHXfD2PDEUbCk5NdPDGzC6AXcofCr1f93Zu5C3n8=; b=ZXV3akCR09SpUvoiQSMg6vWkSjwNKZVygb1kJFL9wV9l8WuSuN7MairN87K5jNhbpR 9b1lNs+RtIP/WOKoY7GrYxDuoYnT+vwwOBBBs8vVSnPpd7/gZxxXomIi6kvaIGW7f6aS CmyM5RNPNmRiXsxIn80spft29xOXUD6URC7gM3MY2iNOUD6mYXkLPfwpxsKgdnrj9kae SEVqFDrbdybDrK8HFfH7p3GNTo2J/r/98nnj6UVBUXYEE0lH5DLKOur0RL1nn2VP5PDa wbo/wptVZRP2abwXqU4tB7t/IKZEmHec5n4nb+uqcnNdjLFeYILosd2lcTLmTToV9M9/ MFig== X-Gm-Message-State: APjAAAX2HI8CIvFbMuW7OQ4kD6gjANkm1g2G9zc59x8KwGoS2m5/dVlv dsFkR2YcL/nDYBa3RBFvPDsjNt3X+Es= X-Google-Smtp-Source: APXvYqzBa/CrOobMmfh3BV9d9Pn6WJxCUU7kKyi8QWtIj3rGQMfmSWBCQHe50Qi8pRiRPcWFvWHbKg== X-Received: by 2002:a5d:6a89:: with SMTP id s9mr24147309wru.58.1553685631351; Wed, 27 Mar 2019 04:20:31 -0700 (PDT) Received: from localhost.localdomain (ipbcc08c44.dynamic.kabel-deutschland.de. [188.192.140.68]) by smtp.googlemail.com with ESMTPSA id h10sm31745448wrs.27.2019.03.27.04.20.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 04:20:30 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org Date: Wed, 27 Mar 2019 12:18:33 +0100 Message-Id: <20190327111852.3784-3-andreas.rheinhardt@googlemail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190327111852.3784-1-andreas.rheinhardt@googlemail.com> References: <20190308092604.3752-1-andreas.rheinhardt@googlemail.com> <20190327111852.3784-1-andreas.rheinhardt@googlemail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/21] avformat/matroskadec: Don't zero unnecessarily 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: , X-Patchwork-Original-From: Andreas Rheinhardt via ffmpeg-devel From: Diego Felix de Souza via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt , robux4@ycbcr.xyz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It is only necessary to zero the initial allocated memory used to store the size of laced frames if the block used Xiph lacing. Otherwise no unintialized data was ever used, so use av_malloc instead of av_mallocz. Also use the correct type for the allocations. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 48b1ba3872..7a96e53bdd 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2796,7 +2796,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, if (!type) { *laces = 1; - *lace_buf = av_mallocz(sizeof(int)); + *lace_buf = av_malloc(sizeof(**lace_buf)); if (!*lace_buf) return AVERROR(ENOMEM); @@ -2808,7 +2808,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, *laces = *data + 1; data += 1; size -= 1; - lace_size = av_mallocz(*laces * sizeof(int)); + lace_size = av_malloc(*laces * sizeof(*lace_size)); if (!lace_size) return AVERROR(ENOMEM); @@ -2818,6 +2818,8 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < *laces - 1; n++) { + lace_size[n] = 0; + while (1) { if (size <= total) { res = AVERROR_INVALIDDATA;