From patchwork Fri Aug 16 00:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 51038 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp84399vqj; Thu, 15 Aug 2024 17:03:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVKzACHj92oFhCNL+G08kEEIwa1tyP8WUbtvnHwPfvFFIMIV3DqeQi3qklLJ9TS4LViocEQwEIMZSwlU3+Flwk3Th5+Bd2VSzB2xw== X-Google-Smtp-Source: AGHT+IHCPqojrHgx5fzPMmFLe+enzvhSkdb8IZbsyAwKw1Mtt/26hF1996+eVOV+P/HuU8elBXPt X-Received: by 2002:a17:907:2d27:b0:a77:cb8b:7a2d with SMTP id a640c23a62f3a-a8392a2a7d4mr76510766b.49.1723766604270; Thu, 15 Aug 2024 17:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723766604; cv=none; d=google.com; s=arc-20160816; b=fnayTWyPdfAdpRT/Zj21A1eIpjxjnMwNHsMCrXHM1mCbU0aMOpqKzQMGzlUy5o2ICH oyUvSevWVAqB2N89O+eEdAYWALQUrn6gjL+HQFpHR0dTgN8QPogSS53ha4A5vJF1qGEP 08u/hnu0MNtq0ce04DyASc+ll7QuKpBavVKD3iVDJpRnf2ePcqHIzGLdfmINwLtQbanL 4tKfJn/XsjKxc/wciNO1hNsn//1i3iOi9Mfai4LPI3LxJ74KXdF2WMTzEp1tW4sQHEwE Xgtqy4MZ0Dzmb7Q/Hr2o1UQcQvZcX/NGP9M0yD0URwUSWueILhoiNaLjbXn1YQ++9/ll fjnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=sA8OazuzriTG7Y74rubaA77lxa/7U8RXEI/04xeoh7Q=; fh=LnlYe9qYwgML7nWWXqAumr7YCmPjjpEPjQf6GasgJC0=; b=ihE9OxQ8WEQeGrCuXCntfRRvQU4AbGEUfr/CkHmaWpt2LgwbF/0UN2soLfLYEvZaW2 lx3dSpkUkxiCUawfLgo0oecDbD318O02PQxCHCO0y/V1f9LbLllLAg7BcFKMhbQzgsMa RWPTWemPiq/t3AHROSqsJ6aIZXhiKMU3IQLciK7qCv6xJUThSIhcB+eNZeZXUuSZhC+w qdP2LIpAIrLJ274wc2YK2NodHXCGmowWE8XWzG8GXYBiD/uMwAiNMxlk5Uri70lWZ850 Hvip2A7g0PU4Fm6KsbRXfD0OaALmGzc9Vr5u46OFY4zOawrbtXClfepYuoO+B81nphuZ nTEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=NrZq5f+b; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rothenpieler.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a83838c7461si135970966b.58.2024.08.15.17.03.23; Thu, 15 Aug 2024 17:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=NrZq5f+b; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rothenpieler.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E613268DB77; Fri, 16 Aug 2024 03:03:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F66068DA3A for ; Fri, 16 Aug 2024 03:03:13 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 099A227FFCF6F; Fri, 16 Aug 2024 02:03:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1723766592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vaL2US23TjWWx/VZa/8Fcfqkaad3wlHIIbGFNPLv5ZY=; b=NrZq5f+bNnEKJLnkxNFLOw7ArmaV2ek27TaruwiumFBXzZbytUy2AM5c7JxDi1pbSQit4l XXYtddsMYKF1VQy5jA0Hn0AWBXCqb4QWoRiMWZJNGolIU0Wt/4DggrQ1zDK8kgMLrkia00 v1e4lQMWtFVNfSa4sgxEbup2mC2pngei/K3AaePguCaF4lsWd6cs66e/Ae0lIDsIsB851u iCRQw13NtQGkYhy/n2C0l5/rINnjeS8hzNCA30GfyNo56RT7mFkeqYSdMLwzBFUAOu/011 mk8q5KSl/6waxUIc1PBLby+4+wCRMYh/D/edQwT4cVscxGSSEDfUdEzb5Z+8VQ== From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Aug 2024 02:02:48 +0200 Message-ID: <20240816000301.61579-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.44.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: correctly reset subtitle stream counter per-varstream X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Timo Rothenpieler Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9OQrY2Sx+EUD Without resetting it, if there was a previous set of varstreams with subtitles, it would subtract from all the streams, leading to chaos and segfaults when trying to access for example stream -1. --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 6d6ede1b6f..1e932b7b0e 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2441,7 +2441,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) int is_ref_pkt = 1; int ret = 0, can_split = 1, i, j; int stream_index = 0; - int subtitle_streams = 0; int range_length = 0; const char *proto = NULL; int use_temp_file = 0; @@ -2449,6 +2448,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) char *old_filename = NULL; for (i = 0; i < hls->nb_varstreams; i++) { + int subtitle_streams = 0; vs = &hls->var_streams[i]; for (j = 0; j < vs->nb_streams; j++) { if (vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {