1 Star 0 Fork 7

wangkang101 / lxcfs

forked from src-openEuler / lxcfs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0005-fix-memory-leak.patch 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
wangkang101 提交于 2020-08-28 15:17 . update to 4.0.5
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index b4f4129..6b503d6 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -224,6 +224,8 @@ static uint64_t get_min_memlimit(const char *cgroup, bool swap)
return log_error_errno(0, ENOMEM, "Failed to allocate memory");
retlimit = get_memlimit(copy, swap);
+ if (retlimit == 0)
+ return retlimit;
while (strcmp(copy, "/") != 0) {
char *it = copy;
@@ -283,6 +285,8 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
prune_init_slice(cgroup);
memlimit = get_min_memlimit(cgroup, false);
+ if (memlimit == 0)
+ return 0;
ret = cgroup_ops->get_memory_current(cgroup_ops, cgroup, &memusage_str);
if (ret < 0)
@@ -1209,6 +1213,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
return read_file_fuse("/proc/meminfo", buf, size, d);
memlimit = get_min_memlimit(cgroup, false);
+ if (memlimit == 0)
+ return 0;
/*
* Following values are allowed to fail, because swapaccount might be
@@ -1237,9 +1243,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
memusage /= 1024;
memlimit /= 1024;
+ char *printme, lbuf[100];
while (getline(&line, &linelen, f) != -1) {
ssize_t l;
- char *printme, lbuf[100];
memset(lbuf, 0, 100);
if (startswith(line, "MemTotal:")) {
1
https://gitee.com/wangkang101/lxcfs.git
git@gitee.com:wangkang101/lxcfs.git
wangkang101
lxcfs
lxcfs
master

搜索帮助