1 Star 0 Fork 18

fandeyuan/btrfs-progs

forked from src-openEuler/btrfs-progs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0003-fix-memory-leak-on-exit-path-in-table-vprintf.patch 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
From 9c156ab9ca53e5fc15730a10d1773da04ea59d4d Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.com>
Date: Wed, 3 Apr 2024 23:13:54 +0200
Subject: [PATCH] btrfs-progs: string-table: fix memory leak on exit path in
table_vprintf()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reported by 'gcc -fanalyzer:
common/string-table.c:62:17: warning: leak of ‘msg’ [CWE-401] [-Wanalyzer-malloc-leak]
The 'msg' still allocated when returning from the function due to error,
free it.
Signed-off-by: David Sterba <dsterba@suse.com>
---
common/string-table.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/common/string-table.c b/common/string-table.c
index 298066c..6d941fa 100644
--- a/common/string-table.c
+++ b/common/string-table.c
@@ -57,6 +57,7 @@ char *table_vprintf(struct string_table *tab, unsigned int column, unsigned int
return NULL;
if (column >= tab->ncols || row >= tab->nrows) {
+ free(msg);
error("attempt to write outside of table: col %u row %u fmt %s",
column, row, fmt);
return NULL;
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fandeyuan/btrfs-progs.git
git@gitee.com:fandeyuan/btrfs-progs.git
fandeyuan
btrfs-progs
btrfs-progs
master

搜索帮助