From patchwork Thu May 16 22:29:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13153 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 66C8644964F for ; Fri, 17 May 2019 01:43:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5529A6809C2; Fri, 17 May 2019 01:43:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 718B9680768 for ; Fri, 17 May 2019 01:43:05 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id j187so4961933wmj.1 for ; Thu, 16 May 2019 15:43:05 -0700 (PDT) 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=hJA4qMXVQBzqXtdqjRga08Z1baocphD5RZP65Vdj7wg=; b=Da/8f26+IGehHsDbWlvjdrJV0hHGlav+um3dgoHbhb4L54MBDADn2vDcB77Vc30r/k YiG2SbA9xbJSbZApEsl4mFlP8fScZXHlsDkFdxRwYN9CIvllsFSnjN3d6aVdO8J06EuA d/YCMj7sYQb6EMxodz810IybhK2j6knF1xBrcQTdN9kj7n2AvKTc5y7shTWu6Bd4EuGw FII7AFqeI0aJFiXBwc4cBKYIlsgEtlFfhuPA+F+nKvZA2P1Z+Rv0lJtF0bJp50nMIJk0 VHm/ZzL58R2PMJfWeumXTXKS3LWsdf5HNdIEWYzTyFdK7ApSaGH7kozBoO91C+VZK+11 OIIQ== 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=hJA4qMXVQBzqXtdqjRga08Z1baocphD5RZP65Vdj7wg=; b=NKTRUjqCPZBCn6fyfhG5UG6AjA47262CP1kYBnEr1HJA+xNY2mVRm+qDIwHUaA1RVP nPrSTAXiP0jDR7PKmi1sf7EEHeGahjr5aGOFlHVyE6tM+ltIcYXtIErLVetMuHFbJy4o vFWg4VYSvO19duhnHfvqkoEx1+0s2tHCJn/nGw9Wn/qtUYRVxCfiNyt8pKJhVqOQX0qq 3zPpKNANIqTHXc7aRwgsbTe4fq6qLudpyBg1WOmivAg6qEcp/8qLps2kxOMr6XH2JnqS t3OLoN/9SgNOSRkxDFL64B/aGCZmcosoEuOu6TRzuecInwSOP6iUIv/xCVX98AEupuI5 IxIw== X-Gm-Message-State: APjAAAVcsT2ICR9nZCx8qXmLtHV2eN1lRMlcM2WGDndIwpRcHFBjc0ir FeVnhgzdQtrsgPDvPpQORsU6HomU X-Google-Smtp-Source: APXvYqzyHvFF2ZylPPlShHV9aHK+DLv8jtWusBHpuGfviCnwaqfEcRUE1ZN9msoLyOu5BWOVhRc98A== X-Received: by 2002:a1c:f30e:: with SMTP id q14mr31426306wmq.31.1558046584806; Thu, 16 May 2019 15:43:04 -0700 (PDT) Received: from localhost.localdomain (ipbcc18715.dynamic.kabel-deutschland.de. [188.193.135.21]) by smtp.gmail.com with ESMTPSA id i185sm11168725wmg.32.2019.05.16.15.43.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 15:43:04 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 May 2019 00:29:48 +0200 Message-Id: <20190516223018.30827-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516223018.30827-1-andreas.rheinhardt@gmail.com> References: <20190516223018.30827-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/37] 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 --- I checked this via the --enable-memory-poisoning compile option. It yielded identical output to patched version without this option as well as to current git head; I used Alexander Noe's AVI-Mux GUI (http://www.alexander-noe.com/video/amg/) to create files using Xiph lacing to test this on. I unfortunately couldn't make Clang's MemorySanitizer or its AddressSanitizer run under MinGW64. libavformat/matroskadec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 3b8ddc5ecb..4dd933ef74 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2814,7 +2814,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); @@ -2826,7 +2826,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); @@ -2836,6 +2836,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;