From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 0A9EE4D237 for ; Mon, 30 Jun 2025 15:02:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 9B77B68E323; Mon, 30 Jun 2025 18:01:44 +0300 (EEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 0732268E2E7 for ; Mon, 30 Jun 2025 18:01:38 +0300 (EEST) Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-7481600130eso2828111b3a.3 for ; Mon, 30 Jun 2025 08:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751295696; x=1751900496; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b1vU5809nm0YYvIs2Qm4vzjoTWWhDh9TNaYsSy9fn6I=; b=M4C8MsvAoNFdlk2pGt58wXuprf4xlvf8eKlge98X7WFKQAa5Ha/m6Agco+y44M7CyJ ylX8JqLUCfKJLwf6sHO4txGfiNiMoZorCUa4NuOzXa8k1PJt17FbV1bu77NLMnAo8OYe 6KlDQ2G8RmcI6zuhpHSAEM6DDyRkZPl8xgmugfqgEVqvU8ECEpD+4CH2zhDC+szwd66y ZTC55xUXOCHP1Y0INh9N2YP5CVVCGiexsZWdJKdsf93hUMajK1WTz+9kVAerz6k7fno8 pSk8GhgE4WCveByBN2iimo7zj5JA1DvYOwcgMC85aHcrasSBPLoDQb+EZ2X7QMwBYRAA R3vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751295696; x=1751900496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b1vU5809nm0YYvIs2Qm4vzjoTWWhDh9TNaYsSy9fn6I=; b=IFh4LND1SaD5TFFhVDRod3K7HGg3h/I2TDPEz0dDEvzx8FVYfqA4im+pq/hR6xoskm 97eRqrYSkCsh5PjS7m26nPNehN2E9mkX5u+dJ2nmPEHyWCIauOztoXrPM4Y5gb7dMPvY FHAnD5Gp2W62JxAttJRPHqlmffrC5MNH6/ckHEKt435NmP8312ynBB342BoQqjFSFrJw dk990SfvkDBUCqLCptlMciywG1e8vcG3UZazfz40BpLzTZSC3xruEjm4w3KXia7H/VHK IeHm4vhmqpj72RIqw5VKYeGEhGcT/u5zH01GpTa2VhNv3/aIS2Myr6u9ZEMRh5zxUS2/ XtbA== X-Gm-Message-State: AOJu0YzL6lz901pEuA7lC0Ckg5bRBxh4J9/bixTqweYSbWae2/U+GwRX OTEX/ulhvxzc/+3zZHrUGwcpIBSc3WF2LeFQawVbWoAhRgwcfx1aK8v3vkjgp6lxF4Hp2w== X-Gm-Gg: ASbGncv651Ii5venz4ZysMusiJIryk+kg8a8+w4I7Z+o1rbjXibjhjtxxNH6CFGqAfz Xvcxtwp4o6TDQJxG+iynN6U4dvA33WkB91oVkuSHs4COOUtuHpSmurFNhvq/LUTigXSTcNoaKy9 ZBCwd7LBSlPTVOQl5zqow4XinEDEiytHRWX5/txHuCthw6+NzfU0DXdp0VUxZnzWjl2GF36CxPR 0ATBcyjxgT6Mq0GB4uyZ3RTLjgnFvgy4UBMm67BZRvNeXqp0e2CfxMtKYFsb0ANqHzQMs/sk6+t Zg7s7qkD4iXcENUunMXMg7bbV4HVwjF6KnhoOtaMGB1ifHW0jiSzn+hxGA7qMT12K70RZXDnoD8 SE6g= X-Google-Smtp-Source: AGHT+IGJSmiuUj2C4++VjSe9HIsYCREniMV13RciX5ni7mzKWIR7wLzj1GRbhFnji6wSdGXsSixhDg== X-Received: by 2002:a05:6a21:a44:b0:21f:53a9:b73a with SMTP id adf61e73a8af0-220a16c9babmr22766961637.39.1751295695891; Mon, 30 Jun 2025 08:01:35 -0700 (PDT) Received: from r760 ([188.253.126.215]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74af541bd0fsm8963434b3a.40.2025.06.30.08.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jun 2025 08:01:34 -0700 (PDT) From: Lidong Yan X-Google-Original-From: Lidong Yan <502024330056@smail.nju.edu.cn> To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 Jun 2025 23:01:13 +0800 Message-ID: <20250630150114.2152464-3-502024330056@smail.nju.edu.cn> X-Mailer: git-send-email 2.50.0.106.gf0135a9047.dirty In-Reply-To: <20250630150114.2152464-1-502024330056@smail.nju.edu.cn> References: <20250630150114.2152464-1-502024330056@smail.nju.edu.cn> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 2/3] avformat/sapenc: fix leak in sap_write_header() 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: Lidong Yan <502024330056@smail.nju.edu.cn> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: In sap_write_header(), ff_format_set_url() assign new allocated new_url to contexts[i]->url but forgot to free it later. Add for loop to free contexts[i]->url before av_free(context). To prevent from writing free-for-loop in every return point, replace `return 0` with `ret = 0` so normal execution can fall through cleanup code. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> --- libavformat/sapenc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 87a834a8d8..0882690ba5 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -244,11 +244,15 @@ static int sap_write_header(AVFormatContext *s) goto fail; } - return 0; + ret = 0; fail: + for (i = 0; i < s->nb_streams; i++) + if (contexts[i]) + av_free(contexts[i]->url); av_free(contexts); - sap_write_close(s); + if (ret < 0) + sap_write_close(s); return ret; } -- 2.50.0.106.gf0135a9047.dirty _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".