[lxc-devel] [lxc/master] cgfsng: use realloc instead of malloc+copy+free
Blub on Github
lxc-bot at linuxcontainers.org
Sat Oct 6 10:43:06 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 355 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181006/a278f2ea/attachment.bin>
-------------- next part --------------
From 5407d095e6c66a5437234520db0252cd570c8d71 Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <w.bumiller at errno.eu>
Date: Sat, 6 Oct 2018 11:12:08 +0200
Subject: [PATCH] cgfsng: use realloc instead of malloc+copy+free
Signed-off-by: Wolfgang Bumiller <w.bumiller at errno.eu>
---
src/lxc/cgroups/cgfsng.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 97913209c..71dfe72e6 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -1377,10 +1377,9 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
return bret;
len = strlen(tmp) + 5; /* leave room for -NNN\0 */
- monitor_cgroup = must_alloc(len);
- (void)strlcpy(monitor_cgroup, tmp, len);
- free(tmp);
+ monitor_cgroup = must_realloc(tmp, len);
offset = monitor_cgroup + len - 5;
+ *offset = 0;
do {
if (idx) {
More information about the lxc-devel
mailing list