3 Star 0 Fork 0

src-oepkgs/vhostmd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0011-util-Fix-potential-memory-leak.patch 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
张一诺 提交于 2022-12-23 17:33 . 1.1
From b39f7cc778903e9cda8aa46d170b9efe80efda89 Mon Sep 17 00:00:00 2001
From: Jim Fehlig <[email protected]>
Date: Tue, 7 Jan 2020 11:41:11 -0700
Subject: [PATCH 11/19] util: Fix potential memory leak
From coverity scan
vhostmd-1.1/vhostmd/util.c:415:14: warning: Potential leak of memory pointed to by 'cp'
return(NULL);
Signed-off-by: Jim Fehlig <[email protected]>
---
vhostmd/util.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/vhostmd/util.c b/vhostmd/util.c
index 1f9545b..599c5c7 100644
--- a/vhostmd/util.c
+++ b/vhostmd/util.c
@@ -415,7 +415,7 @@ char *vu_str_replace(const char *haystack, const char *origstr, const char *news
dest = malloc(strlen(haystack) - (origlen * cnt) + (newlen * cnt) + 1);
if (dest == NULL) {
- return(NULL);
+ goto out;
}
*dest = '\0';
@@ -428,6 +428,8 @@ char *vu_str_replace(const char *haystack, const char *origstr, const char *news
cp = p + origlen;
}
strcat(dest, cp);
+
+out:
free(tempstr);
return dest;
--
2.32.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-oepkgs/vhostmd.git
[email protected]:src-oepkgs/vhostmd.git
src-oepkgs
vhostmd
vhostmd
master

搜索帮助