From patchwork Mon May 4 18:22:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 19500 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 2D17744AD26 for ; Mon, 4 May 2020 21:23:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B41668BEB9; Mon, 4 May 2020 21:23:33 +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 9C4C268BE8A for ; Mon, 4 May 2020 21:23:30 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id r26so609478wmh.0 for ; Mon, 04 May 2020 11:23:30 -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=/Mkpgb1D99YUcu4Z1rogHHuREPWEghIeThLkzaEsXXk=; b=du3b84GtpJUgayCXTe29JcOvEMUJ/YlrUKV2SjLb8514otX38WaZoRVgMJk2eGc1aB el9ld819NYy4ev+PiNxAJGyPfpQK4R0We8QtzNeZYptVjGeQwkLRzfgUUqWrA6dfSIEJ gnchjhvgtlaEcHs68XOVNDRaaaGsb/1rAh3k8Zt4HRHOLNkmGY1ythAaVqJXaTmPwOQa idnE0mN7eY1OLI6t8RvDTQ45nDGOprQ2byBWvUkBXJ+xDa16kDJSFMl/u3uReLEHgq7r /zJahzmbej9LEKq7Ygl0vmexV44/culXhEoo32K5kNCZwfRlHD5JZNpvEPRAVtopJ4oq OprQ== 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=/Mkpgb1D99YUcu4Z1rogHHuREPWEghIeThLkzaEsXXk=; b=EQ+QcCVHpfRKLx5ooWLX1moITfLtWYzyeTj5feo3qpxXLBl2wvDuo1G/PuRanilTCo eEAzyGgpjz/bUK1oH7fuE+CcKg/YcN28K+5GaV+H9S82b9hTP7hn81VoTq7soLYzJWro bxhXDAPQG4GwZ+8UeUoyAz4rLaC9LpMikTzk+vk/C9jQboVEItgUeWlBCaf+4cRGG6YR wGR22P2OWlD4qXiC15aC+tWK3Re1YEEdRH9T86YPmkp7uUyrmDhfp1CIMLg3JgTaZ7PO whOb7c8+YYlYa8iizFrhyUGGYNCtw6WV1f4Kor6Aw5ae3O+VxgqcE9YV1Ppzmn+G1GWg DOxQ== X-Gm-Message-State: AGi0PuZp9JWienuTIOP8cEXR0vKhLg9Wup+3Z8IqpxHrg98IWXtJ+7hH WooVqCLk3UKhhDIyQzaQZBPXHtaM X-Google-Smtp-Source: APiQypKx+MhhQtixdE/3wS//+gZyoqw4125i6KCvJlSxmdgZTDEZy+1fyXo3mjll+BWVt5tZ28mdTg== X-Received: by 2002:a1c:6a0b:: with SMTP id f11mr15896975wmc.123.1588616609474; Mon, 04 May 2020 11:23:29 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id u188sm358595wmg.37.2020.05.04.11.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 11:23:28 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 May 2020 20:22:50 +0200 Message-Id: <20200504182250.26141-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200504182250.26141-1-andreas.rheinhardt@gmail.com> References: <20200504182250.26141-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/10] avformat/nutenc: Don't allocate array with zero entries 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" Allocating an array with zero entries is both unnecessary as well as potentially troublesome because the behaviour in this case is not really well defined. Signed-off-by: Andreas Rheinhardt --- libavformat/nutenc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 6df7dfe210..5071278835 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -711,11 +711,15 @@ static int nut_write_header(AVFormatContext *s) } nut->stream = av_calloc(s->nb_streams, sizeof(*nut->stream )); - nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter)); nut->time_base= av_calloc(s->nb_streams + s->nb_chapters, sizeof(*nut->time_base)); - if (!nut->stream || !nut->chapter || !nut->time_base) + if (!nut->stream || !nut->time_base) return AVERROR(ENOMEM); + if (s->nb_chapters) { + nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter)); + if (!nut->chapter) + return AVERROR(ENOMEM); + } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i];