From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 84A1549541 for ; Sat, 13 Apr 2024 02:44:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE99168D307; Sat, 13 Apr 2024 05:44:36 +0300 (EEST) Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 61ADE68D1AC for ; Sat, 13 Apr 2024 05:44:29 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Content-Type:MIME-Version: Message-ID; bh=PY24nFbvxoxAxQ3ffJumxlHZZK56fTa5Nc3GhnW1h8w=; b=p NAlGgmHV17Q6phMyCVSstNl6o1MmGRTRZQR5ETYEchw/dw6vRkxPiE8BqKhxaAu4 K55mOjxZ0eS2A+/XvDWaWx5SixCnWNrA4qg/7rqE96cTev8BZ2quoImq5tANDzn6 D1qZAzoDgdpHuL60i4MbtkLljGI4dI6VEsC9kckJRM= Received: from lumingyindetect$163.com ( [106.39.130.76] ) by ajax-webmail-wmsvr-40-123 (Coremail) ; Sat, 13 Apr 2024 10:44:25 +0800 (CST) X-Originating-IP: [106.39.130.76] Date: Sat, 13 Apr 2024 10:44:25 +0800 (CST) From: lumingyindetect To: "FFmpeg development discussions and patches" X-Priority: 3 X-Mailer: Coremail Webmail Server Version XT5.0.14 build 20230109(dcb5de15) Copyright (c) 2002-2024 www.mailtech.cn 163com In-Reply-To: References: <20240412164441.1727089-1-lumingyindetect@163.com> MIME-Version: 1.0 Message-ID: <3d47602f.136b.18ed5578109.Coremail.lumingyindetect@163.com> X-Coremail-Locale: zh_CN X-CM-TRANSID: _____wD3nxCJ8RlmHAYUAA--.1675W X-CM-SenderInfo: poxpx0hj1l0vphwhu3i6rwjhhfrp/1tbiTwe-92XAlYqRZAABsO X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_mux_init: fix memory leak in ffmpeg_mux_init.c 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: Thank you for your patient explanation! As you pointed out, I made unnecessary modifications in the public functions in the previous patch. Now, I have rectified them and created a new patch. The patch link is:https://patchwork.ffmpeg.org/project/ffmpeg/patch/20240413023726.1843852-1-lumingyindetect@163.com/ At 2024-04-13 03:11:22, "James Almer" wrote: >On 4/12/2024 1:44 PM, LuMingYin wrote: >> Signed-off-by: LuMingYin >> --- >> fftools/ffmpeg_mux_init.c | 7 ++++--- >> libavutil/mem.c | 5 ++++- >> 2 files changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c >> index 6d8bd5bcdf..e7e2281bd0 100644 >> --- a/fftools/ffmpeg_mux_init.c >> +++ b/fftools/ffmpeg_mux_init.c >> @@ -2851,9 +2851,10 @@ static int parse_forced_key_frames(void *log, KeyframeForceCtx *kf, >> >> if (nb_ch > INT_MAX - size || >> !(pts = av_realloc_f(pts, size += nb_ch - 1, >> - sizeof(*pts)))) >> - return AVERROR(ENOMEM); >> - >> + sizeof(*pts)))) { >> + ret = AVERROR(ENOMEM); >> + goto fail; >> + } >> if (p[8]) { >> ret = av_parse_time(&t, p + 8, 1); >> if (ret < 0) { >> diff --git a/libavutil/mem.c b/libavutil/mem.c >> index b205d3fb25..7f34765fe7 100644 >> --- a/libavutil/mem.c >> +++ b/libavutil/mem.c >> @@ -177,11 +177,14 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize) >> >> if (size_mult(elsize, nelem, &size)) { >> av_free(ptr); >> + ptr = NULL; >> return NULL; >> } >> r = av_realloc(ptr, size); >> - if (!r) >> + if (!r) { >> av_free(ptr); >> + ptr = NULL; >> + } > >This doesn't do what you think it does. ptr is a local variable in this >scope. Setting it to NULL will not be reflected in ffmpeg_mux_init.c >And even if it did, it would be an unexpected behavior change in a >public API function. > >> return r; >> } >> >_______________________________________________ >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". _______________________________________________ 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".