]> git.proxmox.com Git - mirror_lxc.git/commitdiff
cgfsng: use realloc instead of malloc+copy+free
authorWolfgang Bumiller <w.bumiller@errno.eu>
Sat, 6 Oct 2018 09:12:08 +0000 (11:12 +0200)
committerWolfgang Bumiller <w.bumiller@errno.eu>
Sat, 6 Oct 2018 09:12:08 +0000 (11:12 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@errno.eu>
src/lxc/cgroups/cgfsng.c

index 97913209c7fddc2a7ebe3d64af87917a81e10e7f..71dfe72e6f5add916c0bafe614f59982dbcb4283 100644 (file)
@@ -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) {