From patchwork Fri Apr 12 16:44:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LuMingYin X-Patchwork-Id: 48030 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp383189pzb; Fri, 12 Apr 2024 09:45:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWBGywDjHYw4yV79rGmDwo+SU7zteJtCvjGa0Ecn5cNGQd20z0Yr7GvCuZWugTNC29MEpdmMKR7oO2EhJEdAyCl4gU2qp+bpvVLKg== X-Google-Smtp-Source: AGHT+IHuxr9mF7rgm7BJAJRgPXXPFdsoGjc4Xdoa3Z3lO3IFC6Et1Jnc356UvAmJi8S3RUVNp8BZ X-Received: by 2002:a50:8d1e:0:b0:56e:2e4d:884e with SMTP id s30-20020a508d1e000000b0056e2e4d884emr2983950eds.0.1712940305333; Fri, 12 Apr 2024 09:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712940305; cv=none; d=google.com; s=arc-20160816; b=c+PbAM5jjGnzGOZUVKWdjNeT/PJ3TI9MwhCfWk+AXfReOpn0jfSS6eAzlCJbri/a9b 62gb0dKrs+8RvfB9LOYKvt0U+da/0fvGilc8FukVgA8XtAhGjRtzAk8LY16w6AQSDp5O KOReK0Xtn0Sk/SHSq5aM2E8rQJV6lCH9NUb3oS53BjlPyIFQS+Basx+moC49l37ES8wl 1pGS8yl7C1nnaw/In7nolTPr23YirHv79EKWOsQXIXXIEClPTE1QePgR2kuqNP0re8Dk z7tX14iotSFN+/J/oqAz+6tHNtVFpPNk5BdA+HemT6HPVGETg4QVc6tZmAGb04fcVh0L 8Q1A== 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=wgWyWChCXdoXsg5mZR7AHfmZzIZ3FejPiYiL/52rJeo=; fh=h93Jk9zXtjyzsFd9PKvKbdVr/RKQn4bW7LGFE3/Lh8E=; b=OSni5oBpKJSHQaYy5TeW20QIXeNkk7OGlMeCN9VCEN5grNPU8UUweUoyCvQnelyXWj L6vk/bh88mhGhIv4LT0OFy0Xu6yPrlC6lvLAiRwxXPfUKla1h/wogjLeTBIA+cDBii7x YqHS4/VCAj6qgWVmyZJw5x2436tmnIgu7A66wjg2Uwa/rhJcsUiF8V2QS6N1zrHongNZ FoKltJUSw6WyptO7fPh0d3fKR5Z5YX9DZ8I0SfXmOsnByJHXnbgT9pW0NSYztUD8Di3o yhbYbcsMCCdVLGmjBRA782zZqSGmQvUsMs1XRFZ6wmoAnIJKpUBP43qOv+VTO1I0zcR/ 7Eqg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@163.com header.s=s110527 header.b=FhLnMqpZ; 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=163.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v20-20020a50a454000000b0056e075465b0si1813391edb.301.2024.04.12.09.45.04; Fri, 12 Apr 2024 09:45:05 -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=@163.com header.s=s110527 header.b=FhLnMqpZ; 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=163.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9C86968CE20; Fri, 12 Apr 2024 19:45:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4DF1868CE20 for ; Fri, 12 Apr 2024 19:44:53 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=tynTP i+GwYq9mdpA4dPPmw+6KrUu6fH1G7iiPeVD864=; b=FhLnMqpZvmvNBsmbXFay/ 5U6mNotA6ehJaLF6Hegt8025/N0chC5TP+aBsbA7HEEz0ko6785ZC8szerrQ/egC j3ComLVUWxrSQ2cla+3iQg979k2a34qX4huN01vBsScjEYGHMhxEZSnrRyx+dFZE Z6SipMEJ+y9aUZMtW3hD/w= Received: from localhost.localdomain (unknown [111.198.54.11]) by gzga-smtp-mta-g2-4 (Coremail) with SMTP id _____wD3n2j7ZBlmjozWAQ--.50272S2; Sat, 13 Apr 2024 00:44:44 +0800 (CST) From: LuMingYin To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Apr 2024 00:44:41 +0800 Message-Id: <20240412164441.1727089-1-lumingyindetect@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: _____wD3n2j7ZBlmjozWAQ--.50272S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrKF1rJF1UtFyDAr17GFWxWFg_yoWkGwbEgr yxXF18Wry2gFyxCws5GFs8KrWkKa9Y9Fs3ur47tFy5Arsrta4qkFs7XF93ZFySgw4Ikr9r Gws8WrW7Gw4YkjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_5l1JUUUUU== X-Originating-IP: [111.198.54.11] X-CM-SenderInfo: poxpx0hj1l0vphwhu3i6rwjhhfrp/1tbiKR++92VOCczROwAAs7 Subject: [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 Cc: lumingyindetect@163.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: EpvOu8Bv/oUv 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; + } return r; }