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 8AEB850441 for ; Sun, 13 Jul 2025 01:27:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 59E0B68F53C; Sun, 13 Jul 2025 04:27:29 +0300 (EEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id C6CE868F340 for ; Sun, 13 Jul 2025 04:27:22 +0300 (EEST) Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-23694cec0feso29469345ad.2 for ; Sat, 12 Jul 2025 18:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752370040; x=1752974840; darn=ffmpeg.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=tuVReOsK40SBtoAGbUO1mu4EWFxJWHnMbXls9oDOFRg=; b=JM+mAajn73U/VTMAO1cyBCiodbzmlEUCdT7razk6kf0esl9BCnFT5qyMzI4//+6gvf ebJMsZkFqI3V5PLrE7h003DvaAjLDS4i8IODPR3aDjjCyQ+j7uuOoZiih7J6DimT/Mi/ z2Ob8ynniGxtqTrXpHW50Ef8+mSOFEhe+PkggvUQlywchJVhWpWMlP0uYiw7HsRwfD1o 3txiqp92uxAgNjFV+V4XYpx+Q1l+Dtk4zbZZbvrp65pE5fqY60G/AlR7YJp3kpFragAk kKfPJYSPOwsW6Xl0zOIVXGeAZmOcSAgdq3PrLvcbcLIZQeLa5/xsqvS3aGWm5dU9k0SI /pdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752370040; x=1752974840; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tuVReOsK40SBtoAGbUO1mu4EWFxJWHnMbXls9oDOFRg=; b=iVE3aMcqlz0BNY1KhdizOI5TOCEIdO2bg7AaJ8a35+f8JrUrNmuGHbfLBPqIHflCfj Hwa7XVKuWMMOJQZ5HN1+JQbLKmuNLDKF5+HpTKf9R5oWtHrnNd4+pZe2bzizl8K19yHO EILyS0NpJDB0OC0SnUFeiqw7KwkOL+eX1HxfThpImc2D7V/HvHtT65UfZ2WYbPeyuL3C Yeioh1rc+fQb3PTONKroiWsWzAlFkqW3qWX6l9cOggCpKSDSK8kxF50gsVYHVXz6Du43 9U/orrIb2QuM36kKUzOMNwanWUnu2AWtfK1DK/5oj2M0aHO9tXIOpMxLbMe4Nuqm84vu RKtw== X-Gm-Message-State: AOJu0YxYPCpb3EsbH10a6Ts2ld2ypx3hpIHD9TrhnPswxcmHi8OoOnEI wQEIG9FFgYVzrWhDdkzfU6+xVm/62kf40C1oMXNMd8+eBp8N1RLm+ccg1YFPkAXhLnfqE78xjsh lDQ0/iB6/jumfW1DapvhwBcCQ7BvvQAVv+1hBuxA= X-Gm-Gg: ASbGncsjw1ylDD8y4Yy+05csnvrI/UJaTxAYrDW/j2fahhJOQVks7v2oN478fMtEAYT VmG6PqAeY+0MeXd4/MOmVqXv8kh9k/Zny7NXfY8LiCCrLBbEQAYzqZgb5yxAlpuBaGVbID/EHhL WtOOazTI/gNDQs5rvSw9CUpUbnlstyUNAUdC/ID9DMoBbXq7ekySSDgWXLWzR14pXTF8niLlCL6 0NKmjFqJOdPCXTO X-Google-Smtp-Source: AGHT+IFJzovxPv5gD+OCAlDNX9V9ba0G43lCnV5P+tYmPtaearPwQ1pqwbgtA4Vap9B9ITsJhtvtbtUy6BBxrkh+nZI= X-Received: by 2002:a17:902:f603:b0:234:d292:be7f with SMTP id d9443c01a7336-23dede7d45dmr110239725ad.31.1752370040309; Sat, 12 Jul 2025 18:27:20 -0700 (PDT) MIME-Version: 1.0 References: <20250710022047.1847641-1-502024330056@smail.nju.edu.cn> <20250710022047.1847641-2-502024330056@smail.nju.edu.cn> <20250712183303.GC29660@pb2> In-Reply-To: <20250712183303.GC29660@pb2> From: Lidong Yan Date: Sun, 13 Jul 2025 09:27:09 +0800 X-Gm-Features: Ac12FXy9s_-UKp-I7u60NXZt6RraHfEYOkz0FsgVQJJVtpfXRHBEcltK_l7iD9c Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH v2 1/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 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: Michael Niedermayer write: > On Thu, Jul 10, 2025 at 10:20:45AM +0800, Lidong Yan wrote: > > 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 fail > > code. > > > > Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> > > --- > > libavformat/sapenc.c | 13 +++++++++---- > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c > > index 87a834a8d8..0567a754e2 100644 > > --- a/libavformat/sapenc.c > > +++ b/libavformat/sapenc.c > > @@ -233,7 +233,6 @@ static int sap_write_header(AVFormatContext *s) > > ret = AVERROR_INVALIDDATA; > > goto fail; > > } > > - av_freep(&contexts); > > av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", &sap->ann[pos]); > > pos += strlen(&sap->ann[pos]); > > sap->ann_size = pos; > > @@ -244,11 +243,17 @@ static int sap_write_header(AVFormatContext *s) > > goto fail; > > } > > > > - return 0; > > + ret = 0; > > > > fail: > > - av_free(contexts); > > - sap_write_close(s); > > + if (contexts) { > > + for (i = 0; i < s->nb_streams; i++) > > + if (contexts[i]) > > + av_free(contexts[i]->url); > > + av_free(contexts); > > + } > > contexts is an array of AVFormatContext, this does not look right > also freeing the url of the AVFormatContexts that have been stored > in priv_data a few lines earlier looks wrong > I am not sure how to fix then. Maybe I should leave this code alone. Thanks, Lidong _______________________________________________ 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".