From patchwork Mon Dec 16 00:04:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 16812 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 EE5BE44A07A for ; Mon, 16 Dec 2019 02:04:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DDB7468AB3B; Mon, 16 Dec 2019 02:04:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 438DE68A9F4 for ; Mon, 16 Dec 2019 02:04:42 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id p9so4834701wmc.2 for ; Sun, 15 Dec 2019 16:04:42 -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=llPgQq7hh7/k+b53FEbJP1qh5tK9Ho5PuhG0X/AmXE8=; b=IY5J+ci6QdCx4K4ZOej2J3T8B1R4s9dqwanLEj090Fp0EWKo3rRQaWIk8gc/V49Bpd wX/I/pSB+Wooajjk3WprtTii35DGHp+ueoJRhor1PpYQufcsWGpAtCZ1Iq+dN5n3ehxv BCGu15cMRfUxcfWB/ryd0fWCnBV0rIQ9TclmTfZLMFSAed6FCCBq7raf0nYT97UUIUz5 0zIdqMwRIQrQ+aNg9KJVFIoniGFE3a975j5/PvFKMZPnJOYOAAzxvLdPqBqpG7uF9CcH RYVnGlIWmZ3KfiDQqCr4Kzl9Xm++7Gsh2KtYq6M5jsld7ydfuFHdgIv1G5iTlhI5HF8M TQhQ== 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=llPgQq7hh7/k+b53FEbJP1qh5tK9Ho5PuhG0X/AmXE8=; b=hcRsYB0qxzv5zTxYnUU/Eq4NApjLLlqmma1CsXXzQ030nOKHTSXJumaE71Lww50kCo +OWefjku4Zna7GuqDKHaTiiEWfOrKzVLQoLKatV8FL6JrDyAgQyByU/7xDa+ldcwiVbi WsGe58qbmQVmzVTMxQ/Caf5h8LKy45UPXyN84BAuZf9Ta3a8aeGfNC6gUnK0R0LjkiwN MLVxmI2DoTCjY6YO6UulOHKAOViWMERBqH0rRjhihItIl21nKA9SsocqKFJ0ahQfmvjI M1SMJjKlIKmi6hvzU+ahlxXZpIClPn0/H+nt52+Eq7/h842F6J73h50UnaRiNN7GGvxm LSNg== X-Gm-Message-State: APjAAAWSFc+QMvnkkBaAaArBoyJDu8OAM7oQ0PyT5jJsTXoUDBoV57I+ gaeKyL9OCy/jgnNBgu8fL6saQmfi X-Google-Smtp-Source: APXvYqz/JXgDFVedMn7N1PTLi10wWyyZz8ozmEBkppTJEBM4DBa3zG1bPcGxhktX2AYNQt+bRoWjFQ== X-Received: by 2002:a1c:9d52:: with SMTP id g79mr18426482wme.148.1576454681515; Sun, 15 Dec 2019 16:04:41 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08e23.dynamic.kabel-deutschland.de. [188.192.142.35]) by smtp.gmail.com with ESMTPSA id s1sm19214442wmc.23.2019.12.15.16.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Dec 2019 16:04:41 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Dec 2019 01:04:05 +0100 Message-Id: <20191216000418.24707-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191216000418.24707-1-andreas.rheinhardt@gmail.com> References: <20191216000418.24707-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/16] avformat/hlsenc: Only allocate when data is known to be needed 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" hls_init() would allocate a buffer, although it is only needed in one of two branches that follow. This commit moves the allocation to the branch that actually needs the buffer. Signed-off-by: Andreas Rheinhardt --- libavformat/hlsenc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 965c05c560..87bbfb8086 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2906,22 +2906,21 @@ static int hls_init(AVFormatContext *s) ret = AVERROR(ENOMEM); goto fail; } - vs->vtt_m3u8_name = av_malloc(vtt_basename_size); - if (!vs->vtt_m3u8_name ) { - ret = AVERROR(ENOMEM); - goto fail; - } av_strlcpy(vs->vtt_basename, vs->m3u8_name, vtt_basename_size); p = strrchr(vs->vtt_basename, '.'); if (p) *p = '\0'; if ( hls->subtitle_filename ) { - av_freep(&vs->vtt_m3u8_name); ret = format_name(hls->subtitle_filename, &vs->vtt_m3u8_name, i, vs->varname); if (ret < 0) goto fail; } else { + vs->vtt_m3u8_name = av_malloc(vtt_basename_size); + if (!vs->vtt_m3u8_name) { + ret = AVERROR(ENOMEM); + goto fail; + } strcpy(vs->vtt_m3u8_name, vs->vtt_basename); av_strlcat(vs->vtt_m3u8_name, "_vtt.m3u8", vtt_basename_size); }