Merge pull request #2673 from Blub/2018-10-06/cgfsng-alloc-cleanup

cgfsng: use realloc instead of malloc+copy+free
This commit is contained in:
Christian Brauner 2018-10-06 12:58:43 +02:00 committed by GitHub
commit 13c45a4a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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) {