From patchwork Fri Mar 8 09:25:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 12246 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 839F5449027 for ; Fri, 8 Mar 2019 11:26:48 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6ACC668A765; Fri, 8 Mar 2019 11:26:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D573F68A728 for ; Fri, 8 Mar 2019 11:26:46 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id t6so1361306wrw.7 for ; Fri, 08 Mar 2019 01:26:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qYMSgfl3Jh4ClabhrwP9J4g7Qpc+7tdRfayqGethsHA=; b=Qsf50+FFuybLOTmqQ27257pMoNWaqrAVHMLY/4rmwlNuk2oMvBEmlEBGJVUNHkUFrF HkBKxhM1KZyNO+vwLm9zPfrrSCxK77l1sANzHNAWxBZ0WBDQHYtjhQBqmBG1J9iXNgtU NLrdzP2NQ18OgWwA5Rg8z7wcKK0wKyTpjXlO8SuY6PVeSBrSFuanxvE5oyqNSZ4BJUec yoRpWI4O5es7BsVripGg0uTDaP0Mry2wfDcn74YjZPB39WIZumjTpVoHwzF/XQAwCrS7 TXy4mXe3u6gRzwWnL15jQVsUH+1CBPN+IR06i1KqlNCb6PxtAAo3klPxk6HzwQWYdhwg w2rA== 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=qYMSgfl3Jh4ClabhrwP9J4g7Qpc+7tdRfayqGethsHA=; b=AXZXXJsd4Uk1JUDaDQRIOdMdfPBGogaybKEES0gzvGI9oWDHsUsYNDvk0vY82kjac9 pBRFfPIALnPQ3WLAKMzbnGiEOFxBpD5JZBjQ9NQ81bUpqXO9F1vQoXwXt4JAJE7VzZ8r Owo3GZwQPHNhbjm7Ii1gtmzPAEFjLfy3NorhwYq6i2bTRypwjYObpxo+FeuSAra6ohjV 3uoK08i/LUFpzCC7/Agj381gzLsZ0Ed8X/TKAseEILnAY4KLrTBPQ7q+6dNrcz1fccq2 y5VYNkLVTV5Lf/iGu1qY9zB+X0NLt1PRxea2KJlRjyGjl1yciHYiPaWiGtFMWYqsezc/ VzuQ== X-Gm-Message-State: APjAAAVemp7phaCe6JHMjhrE/yBiweedA9lTx6lnwl3uCj3gn8gHAhpY eD/1P78A1+c0roeu/PgxB8OE2ZcPZ+A= X-Google-Smtp-Source: APXvYqwDy5fhAzUeXZdxlUCE6hQpro3bLlXDAq1lHfRTthD840t7sHInQTHPj20LjHk3d52iyQCbRw== X-Received: by 2002:adf:cf05:: with SMTP id o5mr6027783wrj.272.1552037206041; Fri, 08 Mar 2019 01:26:46 -0800 (PST) Received: from localhost.localdomain (ipbcc08c44.dynamic.kabel-deutschland.de. [188.192.140.68]) by smtp.googlemail.com with ESMTPSA id v20sm12179825wmj.2.2019.03.08.01.26.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 01:26:45 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Mar 2019 10:25:56 +0100 Message-Id: <20190308092604.3752-3-andreas.rheinhardt@googlemail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190308092604.3752-1-andreas.rheinhardt@googlemail.com> References: <20190308092604.3752-1-andreas.rheinhardt@googlemail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/10] 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: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt 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 de27d63b17..8a14764d1a 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;